javascript - Firefox 浏览器中的 cssClass.selectorText 更改

标签 javascript css firefox

我在 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/

相关文章:

javascript - 在 javascript 中应用设计模式有什么用?

javascript - 使用 JavaScript 将嵌套对象/关联数组转换为查询字符串

javascript - 如何获得位置固定的元素的高度?

css - 为什么有 std::vector 的迭代器

javascript - Jquery Javascript 仅适用于 chrome 和 firefox,但不适用于 IE

javascript - Onsen UI : button, 底部对齐

javascript - 我遇到 jQuery onclick 问题

javascript - 使用 javascript 延迟自动移动 div

javascript - Draggable 在 Firefox 中惨遭失败

jquery - CSS !important 似乎在 jQuery/Firefox 3.x 中不起作用