Reputation: 6192
My Question is how can I select the .closest('table')
of the .closest('table')
.
I tried:
$('div').closest('table').closest('table').hide();
and it didn't work, is there a way to select the closest table of the closest table?
Upvotes: 0
Views: 2059
Reputation:
You can put an ID at the first table:
<table id="firstTable">
$('div').closest('#firstTable').hide();
Upvotes: 0
Reputation: 148150
Dot missing before first closest
$('div').closest('table').closest('table').hide();
Upvotes: 2
Reputation: 95027
You could use .parents for this:
$('div').parents('table').eq(1).hide();
0 would be closest, 1 second closest, 2 third closest, etc.
Upvotes: 4