【发布时间】:2016-05-25 04:17:16
【问题描述】:
如何将 Z-index 值从 3 更改为 0,如下例所示。它在内联css中。我只需要更改特定类的 z-index 值。它应该是用 JS 编写的,但是完整的代码是用 ES6 编写的。
<div class="xyz" style="position:absolute;z-index:3;top:0;left:0;">
【问题讨论】:
标签: javascript css node.js
如何将 Z-index 值从 3 更改为 0,如下例所示。它在内联css中。我只需要更改特定类的 z-index 值。它应该是用 JS 编写的,但是完整的代码是用 ES6 编写的。
<div class="xyz" style="position:absolute;z-index:3;top:0;left:0;">
【问题讨论】:
标签: javascript css node.js
document.querySelector(".xyz").style.zIndex = 0
这将更改类xyz 的第一个元素的z-index。如果您想为该类的所有元素更改它,请使用 document.querySelectorAll() 并循环遍历元素:
for (const element of document.querySelectorAll(".xyz")) {
element.style.zIndex = 0
}
【讨论】: