Reputation: 807
I have a table formatted data like below in screenshot.
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
Reputation: 468
You can try this:
$('#view_job_tbl > tbody > tr[class*=ChildBundle]').each(function () {
$(this).toggle();
});
Upvotes: 1