博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jquery 全选与反全选
阅读量:745 次
发布时间:2019-03-21

本文共 657 字,大约阅读时间需要 2 分钟。

prop(name|properties|key,value|fn)

name

属性名称
properties
作为属性的“名/值对”对象

$("input[type='checkbox']").prop("checked");

$("input[type='checkbox']").prop("checked", true);

根据以上可以这样写全选与反全选

for

<input type="checkbox" name="mid[]" value="{$vo.userid}" class="checkid"/>

for end

<input type="checkbox" name="checkall" id="checkall" οnclick="checkAll(this)" />

$("#checkall").click(function(){

    $(".checkid").prop("checked", $(this).prop("checked"));
  });

function checkAll(eleObj)

{
$(".checkid").prop("checked", $(eleObj).prop("checked"));
}

function checkAll()

{
var ck = $("#checkall").is(":checked");
$(".checkid").each(function(){
$(this).attr("checked", ck);
})
}

转载地址:http://tefgz.baihongyu.com/

你可能感兴趣的文章