我的模型窗口在引导程序中单击按钮时闪烁?原因?

时间:2014-11-17 11:52:02

标签: jquery html css twitter-bootstrap

下面是我的按钮代码

添加测试用例

这是模型窗口的脚本。

$("#check_all").click(function(event) {
    if(this.checked){

    $(".test").each(function()
        {
        this.checked=true;
            });

    }
    else
        {
        /* this.checked=true; */
        this.checked=false;
        $(".test").each(function(){         
            this.checked=false;
        });
        }
});

我在模型窗口中使用表。任何人都可以猜到这个问题吗?

1 个答案:

答案 0 :(得分:0)

当您使用" .each"时,建议您使用新的上下文来复制当前值以供使用。

你能试试吗?

$("#check_all").click(function(event) {
    var isChecked = this.checked = !this.checked;
    $(".test").each(function(){
        (function (self) {
            self.checked= isChecked;
        })(this);
    });
});