Reputation: 18097
I have html code
<td id="MyNode">TextNode</td>
and would like to make it as
<td id="MyNode"><a href="http://www.domain.com">TextNode</a></td>
I have tried to use code below but what it does is add href attribute to TD element but I need to wrap text with A element.
$('#MyNode').add('a').attr('href', 'http://www.domain.com/');
Upvotes: 0
Views: 476
Reputation: 816292
You can use .wrapInner()
:
$('#MyNode').wrapInner('<a href="http://www.domain.com/"/>');
Upvotes: 3