I want to expand and collapse table rows when header columns is clicked. I only want to expand/collapse rows which are under the specific header (clicked).
Here is m
I would say using the data- attribute to match the headers with the elements inside it. Fiddle : http://jsfiddle.net/GbRAZ/1/
A preview of the HTML alteration :
Header
JS code :
$(".header").click(function () {
$("[data-for="+this.id+"]").slideToggle("slow");
});
EDIT:
But, it involves some HTML changes. so I dunno if thats what you wanted. A better way to structure this would be using or by changing the entire html to use ul, ol, etc or even a div > span setup.