I am trying to identify whether a selected text (in Firefox) is bold or not? For e.g.:
<p>Some <b>text is typed</b> here</p>
<p>Some <span style="font-weight: bold">more text is typed</span> here</p>
The user can either select a part of bold text, or the full bold text. Here is what I am trying to do:
function isSelectedBold(){
var r = window.getSelection().getRangeAt(0);
// then what?
}
Could you please help me?
Thanks
Srikanth
If the selection is within an editable element or document, this is simple:
Otherwise, it’s a little trickier: in non-IE browsers, you’ll have to temporarily make the document editable: