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++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -