Home  >  Article  >  Web Front-end  >  js操作checkbox遇到的问题解决_javascript技巧

js操作checkbox遇到的问题解决_javascript技巧

WBOY
WBOYOriginal
2016-05-16 17:30:48897browse

遇到操作checkbox的问题
全选

复制代码 代码如下:

$("input[type='checkbox']").each(function(){
    this.checked=true
    })
 反选
$("input[type='checkbox']").each(function(){
if(this.checked){
    this.checked=false
    }
    else{
        this.checked=true
        }

 理论上是应该可以用$(obj).attr("checked",true)来操作恶但是在ie下正常,在firfox下反选效果却失灵了,$(obj).removeattr("checked")不起作用,不知道怎么回事。
干脆直接用js操作dom属性,没有问题。
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