复选框实现子节点父节点联动

作者: 麦克劳林 | 来源:发表于2017-05-04 08:25 被阅读36次
  <div class="col-sm-4">
      <h2>球类</h2>
      <div id="epuclass" class="">
        <form>                      
            <input type="checkbox" name="items" value="足球"/>足球
            <input type="checkbox" name="items" value="乒乓球"/>乒乓球
            <input type="checkbox" name="items" value="蓝球"/>篮球
            <input type="checkbox" name="items" value="保龄球"/>保龄球            
            <input type="checkbox" id="CheckedAll"/>全选/全不选                  
            <input type="button" id="send" value="提交"/>
        </form>
      </div>
    </div> 
    
<!--复选框控制  -->
$(document).ready(function(){
    $("#CheckedAllSection").click(function(){
        $("input[name='item']").prop("checked",$(this).is(':checked'));
    });
    var chks = $("input[name='item']");
    chks.click(function(){
    for(var i =0 ; i < chks.length ; i++){ 
        if(!$(chks[i]).is(':checked')){
        $("#CheckedAllSection").removeAttr("checked");
        return ;
        }
    }
    $("#CheckedAllSection").prop("checked",true);
    });
});     
$("#sendSection").click(function(){
    var str="你选中的是:\r\n";
    $('[name=item]:checkbox:checked').each(function(){
        str += $(this).val()+"\r\n";
    });
    alert(str);
});
</script> 



curTypeId = node.tags;
        if (($('#treeview').treeview('getParent', node).text).length > 1) {
            getEquSectionById(node.tags);
            document.getElementById("className").value = $('#treeview').treeview('getParent', node).text;
            curClassId = $('#treeview').treeview('getParent', node).tags;
        }
        else
        {
            getEquClassById(node.tags);
            curClassId = 0;
        }

相关文章

网友评论

  • 大白PM:这篇写的还是略基础哈。
    e2ca90446e4c: @大白PM 你好我是刚学到Js,coreJava学到不是很好,有什么建议么,感觉现在很吃力
    麦克劳林:@大白PM 希望能多多的指导,嘿嘿:heart:
    麦克劳林:我也是刚做前端的东西,开发可能用的东西,都会整理下。

本文标题:复选框实现子节点父节点联动

本文链接:https://www.haomeiwen.com/subject/oftlzttx.html