在按钮上单击出现对应的层,在空白处单击让相应的层消失(在线等) 用div + js能实现的按纽触发事件来改变div属性 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用div+css+js能实现的js事件控制div的css 帮你写了一点,你看一下:<html><head><title>读取网页</title></script><script type="text/javascript"> var msgObj=null; function showLayer(obj,x,y) { msgObj=document.createElement("div");//消息层 msgObj.setAttribute("id","msgDiv"); msgObj.setAttribute("align","center"); msgObj.style.background="white"; msgObj.style.border="1px solid #09f"; msgObj.style.position="absolute"; msgObj.style.left=x; msgObj.style.top=y; msgObj.style.font="12px Verdana,Geneva,Arial"; msgObj.style.width="300px"; msgObj.style.height="200px"; msgObj.style.textAlign="center"; msgObj.style.lineHeight="25px"; msgObj.style.zIndex="10001"; document.body.appendChild(msgObj); } function getPos(el,sProp) { var iPos = 0; while (el!=null) { iPos+=el["offset" + sProp]; el = el.offsetParent; } return iPos; } function removelayer() {//当点击页面时隐藏层 if(event.srcElement.id!="button1" && msgObj!=null) {//判断事件源对象是不是显示层的按钮 document.body.removeChild(msgObj); msgObj=null; } }</script></head><body onclick="removelayer()"><input type="button" id="button1" onclick="showLayer(this,getPos(this,'Left'),getPos(this,'Top')+this.offsetHeight)" value="层一" /></body></html>你的意思不是很明白,什么叫对应的层不一样,把第一个参数传不同的值应该可以吧,或者你只能自己多写几个方法了 请问这两个对象为什么不相等啊 JS问题 求思路 firebug 子页面调用父页面的easyui dialog,如何让其在子页面弹出,而不是在父页面弹出。 js 如果在onclick事件中更换<li>的背景色 怎么在select标签上指定选中项? 很难的问题,在线等 关于table的一个问题!!!! Lostinet(www)(调查显示:我不是人)(com) :我错了。 急。。。关于闭包的问题,解决后,马上给分。 !DOCTYPE 的区别!
js事件控制div的css
<html>
<head>
<title>读取网页</title>
</script>
<script type="text/javascript">
var msgObj=null;
function showLayer(obj,x,y) {
msgObj=document.createElement("div");//消息层
msgObj.setAttribute("id","msgDiv");
msgObj.setAttribute("align","center");
msgObj.style.background="white";
msgObj.style.border="1px solid #09f";
msgObj.style.position="absolute";
msgObj.style.left=x;
msgObj.style.top=y;
msgObj.style.font="12px Verdana,Geneva,Arial";
msgObj.style.width="300px";
msgObj.style.height="200px";
msgObj.style.textAlign="center";
msgObj.style.lineHeight="25px";
msgObj.style.zIndex="10001";
document.body.appendChild(msgObj);
}
function getPos(el,sProp) {
var iPos = 0;
while (el!=null) {
iPos+=el["offset" + sProp];
el = el.offsetParent;
}
return iPos;
}
function removelayer() {//当点击页面时隐藏层
if(event.srcElement.id!="button1" && msgObj!=null) {//判断事件源对象是不是显示层的按钮
document.body.removeChild(msgObj);
msgObj=null;
}
}
</script>
</head>
<body onclick="removelayer()">
<input type="button" id="button1" onclick="showLayer(this,getPos(this,'Left'),getPos(this,'Top')+this.offsetHeight)" value="层一" />
</body>
</html>你的意思不是很明白,什么叫对应的层不一样,把第一个参数传不同的值应该可以吧,或者你只能自己多写几个方法了