Js-Html 前端系列--全选,反选

来源:互联网 发布:灵魂摆渡风华绝代知乎 编辑:程序博客网 时间:2024/05/22 11:14
/* 全选 */    $("#selectedAll").click(function(){        var boxcList = $(".boxc");var boxcList1 = $(".boxcp");        var c = $(this).attr("checked");        if(c == "undefined"||c == undefined||c == false){            boxcList.prop("checked",true);            boxcList.attr("checked",true);            boxcList1.prop("checked",true);            boxcList1.attr("checked",true);            $(this).prop("checked",true);            $(this).attr("checked",true);        }else{            boxcList.removeAttr("checked");            boxcList1.removeAttr("checked");            $(this).removeAttr("checked");        }    });    /* 反选 */    $("#backselectedAll").click(function(){        var boxcList = $(".boxc");var boxcList1 = $(".boxcp");        for(var i=0;i<boxcList.length;i++){            var c = boxcList.eq(i).attr("checked");            if(c == "undefined"||c == undefined||c == false){                boxcList.eq(i).prop("checked",true);                boxcList.eq(i).attr("checked",true);            }else{                boxcList.eq(i).removeAttr("checked");            }        }        for(var i=0;i<boxcList1.length;i++){            var c = boxcList1.eq(i).attr("checked");            if(c == "undefined"||c == undefined||c == false){                boxcList1.eq(i).prop("checked",true);                boxcList1.eq(i).attr("checked",true);            }else{                boxcList1.eq(i).removeAttr("checked");            }        }     });

Js产生两个首尾相连的记时器

<script>var time=0; setTimeout(a(), 1000); alert("开始") function b(){     alert("么么哒 "+time++)     setTimeout(a(), 5000);  } function a(){     alert("萌萌哒 "+time++)     setTimeout(b(), 5000);  }</script>
1 0
原创粉丝点击