Reputation: 4893
In my HTML page DOM what I want to achieve is there is <li>
tag with id 'liPref'
and I want to search if that 'lipref' element has some element whose id contains string 'dlpref'
as its inner HTML.
I am not getting any idea how do I achieve that using jQuery selectors.
Upvotes: 0
Views: 83
Reputation: 38102
You can try to use attribute contains *= selector:
if($("#liPref [id*='dlpref']").length) {
// Existed
}
Upvotes: 1
Reputation: 388316
Try to check whether the liPref element has a an element with id containing the given string
if($('#liPref').has('[id*=dlpref]').length){
alert('foune')
}
Upvotes: 1
Reputation: 82241
Try this:
$("#liPref").find("[id*='dlpref']").each(function(){
//do something here
});
For getting length:
$("#liPref").find("[id*='dlpref']").length;
Upvotes: 2