It is common knowledge that we can retrieve the selection of text in JavaScript using the following method:
var range = window.getSelection ();
However, how can we obtain the style of this selection? For example, when I select bolded text or italicized text, how can I determine their styles?
(One idea I have is to get the position of the selected text and retrieve the HTML at that specific position...)