1. Regarding the hiding and display of specified columns in specified tables
$(" :checkbox[name*=month]").each(function(){
if(!$(this).attr("checked")){
var colnum = $(this).val() ;
$("#listPage").find('tr').find("td:eq(" colnum.toString() ")").hide();
$("#listPage" ).find('tr').find("th:eq(" colnum.toString() ")").hide();
} else {
var colnum = $(this).val( );
$("#listPage").find('tr').find("td:eq(" colnum.toString() ")").show();
$("#listPage ").find('tr').find("th:eq(" colnum.toString() ")").show();
}
});
Or:
$(document).ready(function( ){
$("td:eq(2)",$("tr")).hide();
$("td:eq(3)",$("tr")). hide();
$("td:eq(4)",$("tr")).hide();
$("#button1").click(function(){
$("td:eq(2)",$("tr")).toggle(1000); //Set to 0 to indicate no animation, 1000 to show or hide in 1 second
$("td :eq(3)",$("tr")).toggle(1000);
$("td:eq(4)",$("tr")).toggle(1000);
});
});
2. Get the number of columns in the table
var col = $("#listPage").find("th").prevAll().length;//Get the number of table columns
for(var i =0;i<=col;i ){
if($("#listPage").find('tr').find("th:eq(" i.toString() ")").css ("display")=='none') {//Determine whether the column is hidden
$("input[value=" i "]").attr("checked",false);
} else {
$("input[value=" i "]").attr("checked",true);
}
}
3. In jquery if If you want to find a visible element, use:visible
For example, $("tr:visible")
If you want to find a hidden element, you can use
$("tr:not(':visible')") That's it.