Getting Table Row Of $this Parent Siblings Table !
i have a href link under my table and i want to be able to manipulate table rows by clicking on that link but i cant get them ! here is my html
Solution 1:
You can use find
to get to the tr
from the table
:
$('.removelink').click(function(){
$(this).parent().siblings('table').find('tr:last').remove();
});
Here's a working example. If your HTML structure is always exactly as you've shown, you could use next()
instead of siblings('table')
for slightly shorter code.
The problem with your current code is that siblings('table tr')
will look for a sibling of the div
which is a tr
, and there are none!
Solution 2:
.siblings(selector)
will return all siblings of a certain element which match the selector.
.siblings('table tr')
will only return something if the context element has tr
elements as siblings but the div
does not.
Just use .find
:
$(this).parent().siblings('table').find('tr').last()
Solution 3:
var $context = $(this).parent().siblings('table');
$("tr:last", $context);
Post a Comment for "Getting Table Row Of $this Parent Siblings Table !"