【发布时间】:2010-08-04 19:34:23
【问题描述】:
我正在尝试确定所选文本(在 Firefox 中)是否为粗体?例如:
<p>Some <b>text is typed</b> here</p>
<p>Some <span style="font-weight: bold">more text is typed</span> here</p>
用户可以选择部分粗体文本,也可以选择完整的粗体文本。这是我想要做的:
function isSelectedBold(){
var r = window.getSelection().getRangeAt(0);
// then what?
}
你能帮帮我吗?
谢谢
斯里坎特
【问题讨论】:
-
这是在可编辑元素(或文档)中吗?
标签: javascript format range selection bold