JS多个矩形块选择效果代码(模拟CS结构) 时间:2020-05-12 人气:0 大屏屏幕 <script LANGUAGE="JavaScript"> var canChange = 1; var candraw = 1; function main_mouseup() { candraw = 0; } function init() { var aDivs = document.getElementsByTagName("div"); for (var i=0; iid2)&&(id1%list>id2%list)) {startP = id2;endP = id1;} else{ //alert(DisY); startP = (id1'); }else{ candraw = 0; document.getElementById("startid").value = startId; document.getElementById("endid").value = endId; window.parent.screenEvent(startId,endId,'<%=sSingalID%>'); } } function changeEnd(id) { //获得了最后的一个格子。 if(candraw == 1){ endId = id; //alert(endId); //算法 /* *根据起始ID 和 最后ID来确定是哪些格子变 * 计算start和end的行,列数 */ changeColorBySE(startId,endId); } } function neverDragDivision(fObj) { with (this) { if (!fObj) return; this.bDraged = false; this.oDragOrig = fObj; oDragOrig.onmousedown = function() { oDragOrig.style.backgroundColor="#FFFFFF"; //alert(event.clientY); //alert(oDragOrig.offsetTop); //var ofs = Offset(oDragOrig); // oDragOrig.style.position = "absolute"; //oDragOrig.style.left = ofs.l; //oDragOrig.style.top = ofs.t; //alert(oDragOrig.style.top); //oDragOrig.X = event.clientX - ofs.l; //oDragOrig.Y = event.clientY - ofs.t; bDraged = true; }; /* oDragOrig.onmousemove = function() { if (!bDraged) return; oDragOrig.setCapture(); oDragOrig.style.left = event.clientX - oDragOrig.X; oDragOrig.style.top = event.clientY - oDragOrig.Y; };*/ /* oDragOrig.onmouseup = function() { bDraged = false; oDragOrig.releaseCapture(); };*/ function Offset(e) { var t = e.offsetTop; var l = e.offsetLeft; var w = e.offsetWidth; var h = e.offsetHeight; while(ee=e.offsetParent) { t+=e.offsetTop; l+=e.offsetLeft; } return { t:t, l:l, w:w, h:h } }; }}; </script> <script> document.write(''); document.write(''); number=1; number1=1; var i; up=5; list=8; for(i=0;i<(up*list);i++) { document.write(''); if((i<((up*list)-list))&&(i+1)%list==0) { document.write(''); number++; } } document.write(''); document.write(''); document.write(''); document.write(''); function resetcheck(){ for(i=0;i<(up*list);i++){ changeColorToNotSelected(i); } } </script> [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行] 加载全部内容