首页 > 代码库 > 9月1日收获
9月1日收获
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 onm ousedown="$(this,event)">1</div>
<div onm ousedown="$(this,event)">2</div>
<div onm ousedown="$(this,event)">3</div>
<div onm ousedown="$(this,event)">4</div>
<div onm ousedown="$(this,event)">5</div>
<div onm ousedown="$(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="http://www.mamicode.com/弹出"/>
<!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>
9月1日收获
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。