Can I change the HTML of the selected text?
<p>Can we change the HTML or its attributes of the selected part of the web page using javascript?</p>

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

<p><img src="http://i.stack.imgur.com/9Qa8S.png" alt="enter image description here"></p>

<p>with HTML as</p>

<pre><code>...&lt;p&gt;Sample paragraph&lt;/p&gt;..
</code></pre>

<p>It   is possible to get the HTML of the selected text which has already been answered <a href="http://stackoverflow.com/questions/5643635/how-to-get-selected-html-text-with-javascript">here</a>.</p>

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