您的位置:首页 > Web前端 > JQuery

jquery checkbox checked

2016-03-09 18:11 639 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: