[英]How can I add a span element to an img, then wrap everything with a link?
In my HTML source, I only have: 在我的HTML源代码中,我只有:
<img src="..."/>
Now I want to add a span with jQuery in order to get <img src="..."/><span>My span</span>
, and after this use .wrap()
to wrap it all around a link, to get something like this in the end: 现在,我想使用jQuery添加一个跨度,以获取
<img src="..."/><span>My span</span>
,然后使用.wrap()
将其环绕在链接中,最后得到这样的东西:
<a href="#"><img src="..."/><span>My span</span></a>
What should I do? 我该怎么办?
How about 怎么样
$('img').wrap('<a href="#">').after('<span>My span</span>');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.