Can I change the HTML of the selected text?
===

Can we change the HTML or its attributes of the selected part of the web page using javascript?

For example,
There is a random web page:(A part of it is shown)

![enter image description here][1]

with HTML as

    ...<p>Sample paragraph</p>..
It   is possible to get the HTML of the selected text which has already been answered [here][2].

But, is it possible for me change the html of the selected text? Like, add a class or id attribute to the paragraph tag.


  [1]: http://i.stack.imgur.com/9Qa8S.png
  [2]: http://stackoverflow.com/questions/5643635/how-to-get-selected-html-text-with-javascript