jquery - Find the closest table containing a text -


i've 3 nested tables innermost table containing text in td portion.

what way innermost table containing text?

if run like:

$("td").filter(function(){ return $(this).text().match(/pnr no:/);}).closest('table') 

it gives me 3 tables

it gives me 3 tables

it's returning 3 tables because each td element presumably contains text (since nested).

what way innermost table containing text?

if want select innermost td element, 1 solution select td elements don't contain table elements (i.e., innermost td elements) combining :not() pseudo class , :has() selector:

$("td:not(:has(table))").filter(function() {   return $(this).text().match(/pnr no:/); }).closest('table'); 

jsfiddle demo


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -