jquery 全选与反全选

来源:互联网 发布:wap淘宝什么意思 编辑:程序博客网 时间:2024/05/18 02:25

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" onclick="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);
})
}

0 0
原创粉丝点击