1

我正在使用 SemanticUI 并且 checkall 功能不起作用。这是我的代码

jQuery('.ui.checkbox.selectAll').checkbox( {
    onChange: function(){
        formObj = this[0].form;
        checkall(formObj.SelectAllBox,formObj.UserID);
     }
});

我的检查功能是

function checkall(c,t){
    for(i=0; i<t.length; i++) t[i].checked=c.checked;
}

HTML 代码

<form name="form1" action="action.cfm" method="post">
    <div class="ui checkbox selectAll">
        <input type="checkbox" name="SelectAllBox" value="select_all" >
    </div>
    <div class="ui checkbox">
        <input type="checkbox" name="UserID" value="#UserID#">
    </div>
</form>

我尝试了许多指导和文档,但没有运气。在此先感谢您的帮助。

4

1 回答 1

2

你可以试试这个:

$('input[name="SelectAllBox"]').change(function(){
    if($('input[name="SelectAllBox"]').attr('checked')=='checked'){
        $('input[name="UserID"]').attr('checked',true);
    }else{
        $('input[name="UserID"]').attr('checked',false);
    }
});
于 2014-05-30T13:26:46.907 回答