我需要这样做:
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;
关于javascript - 在ie中用js编辑css报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2744913/