删除 :选中 输入与按钮的文本

Remove :checked from the input with the text of the button

本文关键字:按钮 文本 输入 选中 删除      更新时间:2023-09-26

我将值检查点复制到另一个块。通过单击新元素,必须将其删除并选择过滤器。请帮助查找错误。

    $('.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);
        });

小提琴