【发布时间】:2013-12-18 16:45:29
【问题描述】:
我有一个 contenteditable="true" 的 div,我想获得 所选文本 的背景颜色。它在 Chrome 中运行良好,但在 Firefox 中一直返回“透明”而失败。现在我尝试这样做。 HTML:
<div contenteditable="true" id="selector" style="background-color: rgb(255,255,0);">
Test back<span style="background-color: rgb(255,0,0);">ground</span> color.
</div>
Javascript
$('div#selector').on('mouseup', function (){
alert(document.queryCommandValue('backColor'));
});
示例:http://jsfiddle.net/4Wk2X/11/
你知道为什么会这样吗?
【问题讨论】:
-
你能把你使用的代码贴出来吗?
-
我刚刚发布了一个指向 jsfiddle 的链接。
-
可能与this question相关
-
不,不相关。
标签: javascript firefox backcolor