06011991
06011991

Reputation: 807

Expand even tr tags in table using jquery

I have a table formatted data like below in screenshot.

enter image description here And I need show all tr tags which have ChildBundle class on click of ExpandAll button

Here is the jQuery code I'm using to perform action.

$(document).on('click', '#ExpandAll', function () {
    $('#view_job_tbl > tbody > tr').each(function () {

        var className = $(this).attr('class');
        var number = parseFloat(className.match(/-*[0-9]+/));
        if ($('.ChildBundle' + number + ':visible').length)
            $('.ChildBundle' + number).hide();
        else
            $('.ChildBundle' + number).show();

    });
});

But this is not working. Can somebody help me with this?

Upvotes: 0

Views: 33

Answers (1)

Ciccio
Ciccio

Reputation: 468

You can try this:

$('#view_job_tbl > tbody > tr[class*=ChildBundle]').each(function () {



        $(this).toggle();

});

Upvotes: 1

Related Questions