开发者

How to wrap text with A element

I have html code

  <td id="MyNode">开发者_Python百科;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/');


You can use .wrapInner():

$('#MyNode').wrapInner('<a href="http://www.domain.com/"/>');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜