爱程序网

jquery checkbox checked

来源: 阅读:

1.question:

   when first operate the checkbox with sentence like : 

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

        $("input[type=checkbox]").attr("checkec",false);

    it will succeed;

   but the second time , it will failed.why??

2.Cause:

  if the attribute name of the tag is belong to the tag(the html defined), the prop(name,value) method works,

  if the attribute name of the tag is custom , then attr(name, value) method works.

3. Solution:

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

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

  it works.

关于爱程序网 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助