jQuery: Remove rows based on class

jquery, jquery-selectors

Solution

your code can be much simpler:

$('body').on('click', '.delete', function() {
    var $tr = $(this).closest('tr');
    if ($tr.attr('class') == 'itemRow') {
        $tr.nextUntil('tr[class=itemRow]').andSelf().remove();
    }
    else {
        $tr.remove();
    }
});

see it working here: http://jsfiddle.net/RASG/MeaRQ/

Problem

I've got a problem with jQuery and removing some elements based on their class. See http://jsfiddle.net/JBKp4/1/ When the delete link is clicked in the itemRow the optionRow's and commentRow of that Item should be delete asswell. But I'cant determine the class of the row. I hope somebody can help me out. Thank you!

Original source