1. About the specified table specify column hide display
Copy Code code as follows:
$ (": 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:
Copy Code code as follows:
$ (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 means no animation, 1000 is 1 seconds to show or hide
$ ("Td:eq (3)", $ ("tr")). Toggle (1000);
$ ("Td:eq (4)", $ ("tr")). Toggle (1000);
});
});
2. Get the number of columns in the table
Copy Code code as follows:
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. If you want to find a visible element in jquery: visible
For example $ ("tr:visible")
If you want to find what is not displayed, you can use the
$ ("Tr:not (': Visible ')") on the line.