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.
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.
相关文章推荐
- jquery 获取图片大小
- 【error】jQuery.ajax()报错Uncaught SyntaxError: Unexpected token
- jQuery对象相互转换成DOM对象
- jQuery中 end(); 的用法
- jquery.validate.js常用扩展函数
- jQuery 根据JSON数据动态生成表格
- Ajax
- 关于JQuery 中$.ajax函数利用jsonp实现Ajax跨域请求ASP.NET的WebService成功获取数据的案例
- jquery checkbox 全选 全不选 反选
- HTML5:多文件上传 Upload multiple files at once with HTML5, jQuery and PHP
- jQuery全屏滚动插件fullPage.js
- jQuery的动画效果
- php ajax json jquery 记录
- jquery如何判断checkbox(复选框)是否被选中
- jQuery操作select下拉框的text值和value值的方法
- <学习笔记> jQuery.extend 函数详解
- jQuery父级以及同级元素查找介绍
- jquery学习笔记--基础介绍
- HTML--10Jquery
- jquery 和 js 如何获取单选框的值