本文實例講述了jQuery切換所有復選框選中狀態的方法。分享給大家供大家參考。具體如下:
這段代碼非常簡單實用,通過鏈接切換所有checkbox是否選中
var tog = false;
// or true if they are checked on load
$('a').click(function() {
$("input[type=checkbox]").attr("checked",!tog);
tog = !tog;
});
希望本文所述對大家的jquery程序設計有所幫助。