How do I add an attribute to a link inside a textarea?
Here is my code:
HTML
<textarea id="text"><a href="/" id="link">Click here</a></textarea>
<a href="#" id="add_attr">Add attribute</a>
<a href="#" id="remove_attr">Remove attribute</a>
JavaScript, JQuery
$(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;
});
});