How do I add an attribute to a link inside a textarea?
<p>How do I add an attribute to a link inside a textarea?</p>

<p>Here is my code:</p>

<p><strong>HTML</strong></p>

<pre><code>&lt;textarea id="text"&gt;&lt;a href="/" id="link"&gt;Click here&lt;/a&gt;&lt;/textarea&gt;

&lt;a href="#" id="add_attr"&gt;Add attribute&lt;/a&gt;
&lt;a href="#" id="remove_attr"&gt;Remove attribute&lt;/a&gt;
</code></pre>

<p><strong>JavaScript, JQuery</strong></p>

<pre><code>$(document).ready(function()
{
    $('#add_attr').click(function()
    {
        var value = $('#text').val();

        //add attribute `class="name"` to the link inside the textarea
        return false;
    });

    $('#remove_attr').click(function()
    {
        var value = $('#text').val();

        //remove attribute `class="name"` from the link inside the textarea
        return false;
    });
 });
</code></pre>
