javascript - why $(':not(:has(*))').find("p"); won't give an output -
i wanted parent node of text, , know it's not possible , should done manual traversing. want know why following not working.
$(':not(:has(*))').find(':contains("mytext")');
i made easier looking p tag in result. know $(':not(:has(*))');
return p tags .find("p");
should select p tags
i know it's not working want know why?
you're trying find descendant elements of elements no descendants. that's not going work.
if you're looking p
elements no descendants, meant use .filter()
, not .find()
:
$(':not(:has(*))').filter('p')
or can attach p
selector :not()
— there no reason run separate selector here (unless selector string coming variable or something):
$('p:not(:has(*))')
Comments
Post a Comment