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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -