我不知道为什么我的脚本不能在Firefox上使用,而在谷歌浏览器上却不能使用
JS:
var _timelineWidth = (Number.parseInt(document.styleSheets[0].cssRules[16].style.width) / 100) * document.body.clientWidth;
Run Code Online (Sandbox Code Playgroud)
CSS:
#timeline {
position: relative;
top: 15px;
left: 12.5%;
height: 5px;
background: #aaa;
border-radius: 2.5px;
cursor: pointer;
}
Run Code Online (Sandbox Code Playgroud)
这是chrome的错误代码
未捕获的DOMException:无法从“ CSSStyleSheet”读取“ cssRules”属性:无法访问规则
这是我的 JS 代码:
for (var i=0;i<document.getElementsByClassName('box').length ;i++) {
//code here
}
Run Code Online (Sandbox Code Playgroud)
我想知道如何只选择奇数或偶数 i