I want append <span></span>
tag in my every <a>
tag:
now:
<a href=#>aaa</a>
<a href=#>bbb</a>
<a href=#>ccc</a>
I want:
<a href=#><span>aaa</span></a>
<a href=#><span>bbb</span></a>
<a href=#><span>ccc&l开发者_开发技巧t;/span></a>
now ,i using below codes to implement it:
$(function(){
var buttons = $("a");
var text=buttons.text();
buttons.text("");
buttons.prepend("<span>"+text+"</span>");
});
I think this codes is not good,how to simplify it?
thanks :)
I think What you are looking for is the wrapinner function.
$("a").wrapInner("<span></span>")
You can find a working example here.
精彩评论