0

チェックボックスを置き換えるプラグインを作成していますが、IE8 以外のすべてのブラウザーでうまく機能しています (IE7 や IE6 は気にしません)。

selectedチェックボックス属性を で設定すると問題が発生しますtoggleClass()
これはバグですか?

http://jsfiddle.net/amSdM/36/

コード: $.fn.replaceCheckbox = function() {

    this.each(function(){

        if ($(this).val() !== '') { 
            $(this).attr('value', $(this).parent().text());
        }

        var checkbox = $(this);

            checkbox
                .hide()
                .removeAttr('checked')
                .before('<span>&nbsp;</span>')
                .click(function(){
                    $(this).prev('span').toggleClass('selected', checkbox.is(':checked'));
                });
        });
};
4

1 に答える 1

0

交換

 $(this).attr('checked', true);

 $(this).attr('checked', 'checked');

やるべきです:)

于 2011-04-28T01:11:12.300 に答える