js中设置class:
document.getElementById("divID").className="mydivclass";
链接:
addEventHandler(this.Drag, "mousedown", BindAsEventListener(this, this.Start));
http://www.cnblogs.com/cloudgamer/archive/2008/11/17/Drag.html
http://www.cnblogs.com/dolphinX/archive/2012/10/13/2722501.html
http://www.cnblogs.com/shiyangxt/archive/2008/11/16/1334633.html滤镜
div拖动
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><style type="text/css">#main div{position:absolute;width:220px;height:150px;border:1px solid #999;}</style><script type="text/javascript">var a;document.onmouseup=function(){if(!a)return;document.all?a.releaseCapture():window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);a="";};document.onmousemove=function (d){if(!a)return;if(!d)d=event;a.style.left=(d.clientX-b)+"px";a.style.top=(d.clientY-c)+"px";};function $(o,e){a=o;document.all?a.setCapture():window.captureEvents(Event.MOUSEMOVE);b=e.clientX-parseInt(a.style.left);c=e.clientY-parseInt(a.style.top);}</script></head><body> <div id="main"> <div onmousedown="$(this,event)">1</div> <div onmousedown="$(this,event)">2</div> <div onmousedown="$(this,event)">3</div> <div onmousedown="$(this,event)">4</div> <div onmousedown="$(this,event)">5</div> <div onmousedown="$(this,event)">6</div> </div></body></html>
判断哪控件获得焦点
function isActive(id){ var obj=document.activeElement; if (obj==null) return false; return obj.id==id;} 判断那个获得焦点
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>Div + CSS Example, Wayhome‘s Blog</title> </head> <body onkeyup="test(event)"> <input type="text" id="shuru1"> <input type="text" id="shuru2">
<input type="text" id="shuru3"> <script> var myInput = document.getElementsByTagName(‘input‘); function test(event){
for(var i=0;i<myInput.length;i++){
if (myInput[i] == document.activeElement) {
te=myInput[i];
}
}
if (te == document.activeElement) {
} else {
if(70==event.keyCode){
alert("快捷键");
}
}
} </script> </body> </html>
<div id="zshuju">dfa</div>
<input type="button" onclick="javascript:alert(document.getElementById(‘zshuju‘).style.zIndex)" value="弹出"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>Div + CSS Example, Wayhome‘s Blog</title> </head> <body onkeyup="test(event)"> <input type="text" id="shuru"> <script> function test(event){
for(var i=0;i<myInput.length;i++){ if (myInput[i] == document.activeElement) {
te=myInput[i];
}
}
if (te == document.activeElement) {
} else {
if(70==event.keyCode){
alert("快捷键");
}
}
} </script></body> </html>
时间: 2025-01-01 21:24:32