动态改变div的z-index属性的简单实例
2023-06-13 09:15:04 时间
<scriptlanguage="javascript">
varMAX_INDEX=4;
functionchange(ddd)
{
if(ddd.style.zIndex<=MAX_INDEX)
{
ddd.style.zIndex=MAX_INDEX+1;
MAX_INDEX++;
}
}
</script>
<divid="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>
<divid="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>
<divid="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>
<divid="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>
相关文章
- iOS小技能:动态地给类添加新的方法、实例变量、属性。
- 【说站】python类属性和实例属性的区别
- vue父组件调用子组件属性_vue子组件获取父组件实例
- 徐大大seo:外贸独立站SEO优化推广实例分析
- 实例如何同时运行两个Redis实例(可以同时开2个redis)
- 实例学习Javascript之构建方法、属性
- 配置MySQL与卸载MySQL实例操作
- JQuery验证jsp页面属性是否为空(实例代码)
- Javascript实现滚动图片新闻的实例代码
- PHP提取图片img标记中的任意属性的简单实例
- js动态调用css属性的小规律及实例说明
- Python中字典(dict)和列表(list)的排序方法实例
- thinkphp模板继承实例简述
- GO语言文件的创建与打开实例分析
- VC++简单实现关机、重启计算机实例代码
- C#关于类的只读只写属性实例分析
- js面向对象之静态方法和静态属性实例分析
- python私有属性和方法实例分析
- Python的类实例属性访问规则探讨