I have a list of items inside a table. I have decided to change the table structure a bit so that things look more organized, and added some more <tr>
's in. What happened is that my jQuery code doesn't work well anymore.
I have that piece of code:
$(':input:not(.ajax-confirmed)').each(function(m,r){
var $row = $(r).closest('tr');
$row.remove();
});
I would simply like to select the closest <tr>
and signify it with an additional parameter, I thought maybe a class, so that I know what kind of <tr>
I am removing.
How can I select the closest tr with a specific class name?
This should work, depending on your HTML structure:
$(':input:not(.ajax-confirmed)').each(function(m,r){
var $row = $(r).closest('tr.className');
$row.remove();
});
Hope this helps!
If you look in the documentation, you will find this example:
$('li.item-a').closest('ul', listItemII)
.css('background-color', 'red');
The second parameter coult be a class name. So in your example, just add something like this:
var $row = $(r).closest('tr', 'some class name');
"I would simply like to select the closest "
.closest('tr')
or
.closest('.myclass')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.