Home  >  Article  >  Web Front-end  >  jQuery checkbox select all/unselect all implementation code_jquery

jQuery checkbox select all/unselect all implementation code_jquery

WBOY
WBOYOriginal
2016-05-16 18:41:45958browse

jQuery版本:1.3.2

复制代码 代码如下:






1

2

3

4

全选/取消全选




jQuery.attr 获取/设置对象的属性值,如:
复制代码 代码如下:

$("input[name='chk_list']").attr("checked"); //读取所有name为'chk_list'对象的状态(是否选中)
$("input[name='chk_list']").attr("checked",true); //设置所有name为'chk_list'对象的checked为true

再如:
复制代码 代码如下:

$("#img_1").attr("src","test.jpg"); //设置ID为img_1的src的值为'test.jpg'
$("#img_1").attr("src"); //读取ID为img_1的src值

下面的代码是获取上面实例中选中的checkbox的value值:
复制代码 代码如下:



哪位高手能把上面遍历的过程用$.each()写出来,不胜感激。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn