JS多个复选框点击显示与隐藏,复选框点击事件



```javascript
//复选框事件
    var chType=document.getElementsByName("supplier_u.change_type");
    //单个点击复选框
    var str1="";
    $("#trCompany").hide();
    $("#trLegal").hide();
    $("#trAddress").hide();
    $("#trRate").hide();
    $("#tbody2").hide();
    $("#tbody3").hide();
    for(var i=0;i<chType.length;i++) {

        chType[i].onchange=function() {
            if(this.checked) {
                show(this.value,true);
            }else {
                show(this.value,false);
            }
        }
        if (chType[i].checked) {
            var bb=i.toString();
            show(bb,true);
        }

    }
function show( d,type) {
        switch (d) {
            case "0":
                if(type) {
                    $("#trCompany").show();
                    break;
                }else{
                    $("#trCompany").hide();
                    break;
                }
            case "1":
                if(type) {
                    $("#trLegal").show();
                    break;
                }else{
                    $("#trLegal").hide();
                    break;
                }
            case "2":
                if(type) {
                    $("#trAddress").show();
                    break;
                }else{
                    $("#trAddress").hide();
                    break;
                }
            case "3":
                if(type) {
                    $("#trRate").show();
                    break;
                }else{
                    $("#trRate").hide();
                    break;
                }
            case "4":
                if(type) {
                    $("#tbody2").show();
                    break;
                }else{
                    $("#tbody2").hide();
                    break;
                }
            case "5":
                if(type) {
                    $("#tbody3").show();
                    break;
                }else{
                    $("#tbody3").hide();
                    break;
                }
        }
}

```javascript
在这里插入代码片

版权声明:本文为qq_31647655原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。