javascript - 在ie中用js编辑css报错

标签 javascript css internet-explorer edit

我需要这样做:

document.styleSheets[i].rules[1].style.cssText = "cursor: url(images/grabbing.cur), default !important;";

如果我正在检查:

alert(document.styleSheets[i].rules[1].style.cssText);

它给出:光标:!important

为什么不在这个 css 中设置整个字符串?

仅在 Internet Explorer 中存在问题,在 Firefox 中有效。

最佳答案

一个简单的技巧:不需要“, default”。

在 css 中,字符“,”只是用来分隔列表中的元素,例如:

font-family: tahoma, times;

cursor 属性不接受系列作为值。

您的 CSS 的正确形式:

cursor: url(images/grabbing.cur) !important;

羽读:http://www.w3schools.com/css/pr_class_cursor.asp

关于javascript - 在ie中用js编辑css报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2744913/

相关文章:

javascript - 划线粗底细顶-车速表指针

javascript - Ember.js 中具有相同事件的多个混合

javascript - 引用外部选项值或函数

javascript - 样式化和折叠无序列表

css - 无法将一个 div 置于另一个 div 中

html - 在 Ghost 主题中居中 img

internet-explorer - 跨域窗口之间的 postMessage 在 IE10 中不起作用(它适用于框架)

javascript - 如何将需求片段从 var 切换为 const?

jquery - Jscrollpane 导致文本在 Internet Explorer 上消失

JavaScript:打印完整网页时,IE 似乎没有在页面上打印 iFrame 的内容