Show/ Hide Table Column with colspan using jQuery
Solution 1:
Hi now used to this
Jquery
$(document).ready(function(){
$("#show").click(function(){
$("#showhide").show();
});
$("#hide").click(function(){
$("#showhide").hide();
});
})
and some change to your html
Live demo
Solution 2:
Or you can use nth-child
selector:
$('input').click(function(){
if($(this).val() == "Hide Associate"){
$('th:nth-child(2), td:nth-child(2), th:nth-child(3):not(:first), td:nth-child(3), th:nth-child(4), td:nth-child(4), th:nth-child(5), td:nth-child(5)').hide();
}else{
$('th:nth-child(2), td:nth-child(2), th:nth-child(3):not(:first), td:nth-child(3), th:nth-child(4), td:nth-child(4), th:nth-child(5), td:nth-child(5)').show();
}
});