I'd like to implement such a function on a web page: When called, it checks whether there are some text selection(often displayed as inverted colored text) on the page, if yes, insert an element <img src="my.png"/>
just before the first word of the selection.
Pure JavaScript or jQuery code are both welcome, jQuery preferable. Thank you.