原生js设置 z-index
时间: 2023-11-08 20:16:57 浏览: 219
要通过原生JavaScript设置z-index属性,可以使用以下代码:
```javascript
document.getElementById('normaldiv1').style.zIndex = '10';
```
这将把具有id为"normaldiv1"的元素的z-index属性设置为10。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [在JavaScript中获取DIV的z-index?](https://blog.csdn.net/weixin_34872032/article/details/117896422)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [原生js写轮播图——用属性方法z-index层级或display:none显示](https://blog.csdn.net/weixin_42132833/article/details/107680122)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文