我在 firefox 浏览器上尝试更改 css 类上的选择器文本时遇到问题。
我尝试过的:
for (var i = 0; i < document.styleSheets.length; i++) {
styleSheet = document.styleSheets[i];
for (var j = 0; j < styleSheet.cssRules.length; j++) {
rule = styleSheet.cssRules[j];
// identifies the keyframe rule bearing the same name as the class without the point in the beginning
if ((rule.type == rule.KEYFRAMES_RULE || rule.type == rule.WEBKIT_KEYFRAMES_RULE) && rule.name === className.substr(1)) {
keyframesRule = rule;
}
// identifies the class rule named like the function argument effect
if (rule.selectorText == className) {
animationRule = rule;
mainSheet = styleSheet;
}
}
}
for (var l = 0; l < nrOfElements; l++) {
classAttributes = animationRule.cssText;
mainSheet.insertRule(classAttributes, mainSheet.cssRules.length);
newClasses = mainSheet.cssRules[mainSheet.cssRules.length - 1];
newClasses.selectorText = newClassName[l];
console.log(newClasses.selectorText);
console.log(newClassName[l]);
newClasses.style.setProperty((vendorPrefix + "animation-name"), newClassName[l].substr(1));
}
不幸的是,第一个控制台返回 .WPANIM
而第二个返回 .WPANIM + incrementor
。
问题:
为什么 cssClass.selectorText
在 firefox 浏览器上不能被其他东西改变?
最佳答案
设置 .selectorText 未在 Firefox 中实现 https://bugzilla.mozilla.org/show_bug.cgi?id=37468
这个问题已经存在 16 年了,请随意投票或修复它)
关于javascript - Firefox 浏览器中的 cssClass.selectorText 更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34718932/