I want to read if a certain text in a contenteditable element is bold or not. In Chrome document.queryCommandValue("bold")
returns "true"/"false"
as a string, IE returns a true/false
as a boolean, but Firefox returns (empty string)
in the developer console.
I made a fiddle as an example: http://jsfiddle.net/nTQd2/
If you write som text in the div, mark it and then hit "Bold" the span should show "true"/"false"
or true/false
. I don't really care if its as a string or a boolean as I can convert it later.
For bold, italic and similar, use document.queryCommandState()
. Use document.queryCommandValue()
for non-Boolean commands.