正文

动态改变div的z-index属性2007-08-13 13:07:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/wangsdong/28447.html

分享到:

<script   language="javascript">  
  var   MAX_INDEX=4;  
  function   change(ddd)  
  {  
  if(ddd.style.zIndex<=   MAX_INDEX)  
  {  
  ddd.style.zIndex   =   MAX_INDEX+1;  
  MAX_INDEX++;  
  }  
  }  
  </script>  
  <div id="layer1" onclick="javascript:change(this);"  style="position:absolute;margin-left:100;margin-top:50px;margin-=100;width=100;height=100;background-color:#ff0000;z-index:1"></div>  
  <div id="layer2"   onclick="javascript:change(this);"   style="position:absolute;margin-left:120;margin-top:60px;margin-=120;width=100;height=100;background-color:#00ff00;z-index:2"></div>  
  <div id="layer3"   onclick="javascript:change(this);"   style="position:absolute;margin-left:140;margin-top:70px;margin-=140;width=100;height=100;background-color:#0000ff;z-index:3"></div>  
  <div id="layer4"   onclick="javascript:change(this);"   style="position:absolute;margin-left:160;margin-top:80px;margin-=160;width=100;height=100;background-color:#000000;z-index:4"></div>

阅读(7565) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册