Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的 HTML 源代码中,我只有:
<img src="..."/>
现在我想用 jQuery 添加一个 span 以获得<img src="..."/><span>My span</span>,然后使用.wrap()它来将它全部包裹在一个链接周围,最后得到这样的东西:
<img src="..."/><span>My span</span>
.wrap()
<a href="#"><img src="..."/><span>My span</span></a>
我应该怎么办?
怎么样
$('img').wrap('<a href="#">').after('<span>My span</span>');
http://jsfiddle.net/Ykdgd/