Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find parent table tag from td

How do I get to the parent table tag from the td I am currently in?

I tried .parents('table') but that selects all tables outside the td, I just need the current one

like image 368
jim smith Avatar asked Nov 23 '11 09:11

jim smith


People also ask

How do you find the parent element in JQ?

The parent() is an inbuilt method in jQuery which is used to find the parent element related to the selected element. This parent() method in jQuery traverse a single level up the selected element and return that element. Here selector is the selected elements whose parent need to find.

How can get TD of TR in jQuery?

jQuery(". dname"). find("tr td:eq(1)"). val();


1 Answers

You need to use closest() function:

$('td').closest('table'); 
like image 92
Samich Avatar answered Oct 02 '22 16:10

Samich