To have columns hidden automatically for checkboxes that are hidden by default (page load), use the following code along with the click element to toggle the columns:$("input:checkbox:not(:checked)").each(function() { var column = "table ." + $(this).attr("name"); $(column).hide();});$("input:checkbox").click(function(){ var column = "table ." + $(this).attr("name"); $(column).toggle();});演示: http://jsfiddle.net/highwayoflife/8BahZ/4/ 此示例还使用了一个选择器,例如:$('table .class_name');如果您在较大的页面上使用代码,则它将是一个更快的选择器,因为它不必搜索每个DOM元素来查找类名,而是仅在表下查找.This example also uses a selector like: $('table .class_name'); which will be a faster selector if you are using the code on a larger page since it won't have to search through every DOM element to find the class names, it only looks under tables. 这篇关于通过使用jQuery选中复选框来自动隐藏表列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-03 01:19