``attr(' checked&#39 ;, false)''在IE6上不起作用 [英] `attr('checked', false)` not working on IE6

查看:102
本文介绍了``attr(' checked&#39 ;, false)''在IE6上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所述,我无法使用.attr('checked', false)在IE6上工作.我正在克隆一些HTML,然后在将新克隆的HTML分配给一个元素之前,先运行它并取消选中新克隆"部分中的所有复选框,该复选框在IE 6以外的所有浏览器中都可以正常工作.

这是代码:

    //give each input and select a custom id
    clone.find('input, select').each( function( i ) {

            //get the id attribute
            var id = $(this).attr('id');

            //uncheck all of the tick boxes
            $(this).attr('checked', '');

            //get the name attribute
            var name = $(this).attr('name');

            $(this).attr('name', name+"_"+count)
            $(this).attr('id', id+"_"+count+"_"+i)

    });

    //append the newly created area to the area wrapper
    clone.appendTo('[data-custom="area_wrapper"]');

有什么办法可以解决这个问题?

解决方案

尝试

.removeAttr("checked")

As the title says, I can't get .attr('checked', false) to work on IE6. I am cloning some HTML and then before I assign the newly cloned HTML to a element, I run through it and un-check all of the checkboxes that are in the newly cloned section, which works fine in all browsers except IE 6.

Here is the code:

    //give each input and select a custom id
    clone.find('input, select').each( function( i ) {

            //get the id attribute
            var id = $(this).attr('id');

            //uncheck all of the tick boxes
            $(this).attr('checked', '');

            //get the name attribute
            var name = $(this).attr('name');

            $(this).attr('name', name+"_"+count)
            $(this).attr('id', id+"_"+count+"_"+i)

    });

    //append the newly created area to the area wrapper
    clone.appendTo('[data-custom="area_wrapper"]');

Is there any way that I can work around this problem?

解决方案

Try

.removeAttr("checked")

这篇关于``attr(' checked&#39 ;, false)''在IE6上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆