javascript - 删除:checked from the input with the text of the button

标签 javascript jquery

我将值检查点复制到另一个 block 。通过单击新元素,必须删除它以及过滤器选择。请帮忙找出错误。

    $('.views-exposed-widget').on('change', 'input', function () {
        var self = $(this),
            name = this.name,
            text = self.closest('.form-type-radio').find('label[class="option"]').text(),
            target = $('.duplicate-filter').find('[data-for="'+ name +'"]');

        if (target.length == 0){
            target = $('<span class="o_filt" data-for="'+name+'"></span>').appendTo('.duplicate-filter');
        }
        target.text( text );

        $('.o_filt').on('click', function(){
            var l = $(this).text();
                m = $('.views-exposed-form .form-type-radio label.option');
            $(this).remove();
            m.each(function(){
                if($(this).text().indexOf(l)!=-1){
                    $(this).closest('input[type="radio"].dls-radio').removeAttr('checked');                     
                }
            });
        });

    }); 

示例:http://jsfiddle.net/e59ogp8a/5/

最佳答案

使用 .prop('checked', false) 像这样:

        $('.o_filt').on('click', function () {
            var l = $(this).text();
            $(this).remove();
            $('input[name="' + $(this).data('for') + '"]').prop('checked', false);
        });

FIDDLE

关于javascript - 删除:checked from the input with the text of the button,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27021415/

相关文章:

javascript - 如何将两个依赖的 GraphQL 查询与 'compose' 结合起来?

javascript node module.exports/require() 前端代码

javascript - 什么时候在 javascript 中声明一个新的(匿名)函数?

javascript - Node.js 异步系列无法按顺序工作

javascript - getJSON 显示 [object Object] 而不是实际值

javascript - 如何将这段小代码从 Extjs3 升级到 Extjs4.2?

javascript - Page/Div 内容在点击时淡入淡出

jquery 在表格底部添加一行

低分辨率下的 jQuery 旋钮

javascript - 执行函数查看 JSON 文件是否包含特定字符串