[英]Appending html element with jQuery - differences between html, DOM and jQuery append?
[英]on dom ready append html element using jquery
我有一个带有其余html源的保留数据库,供客户端用来渲染一些页面摘要。 我想获取#mainNewsBody .news p
所有图像,并添加指向该图像的链接rel='superbox[image]'
现在是
<img src="http://www.mysite.com/images/DSCF1087.JPG" />
,它应该是
<img src="http://www.mysite.com/images/DSCF1087.JPG" rel='superbox[image]'/>
如何在dom ready上使用jquery达到此目的?
感谢大家。
$(function(){
$('#mainNewsBody .news img').attr('rel', 'superbox[image]');
});
$(document).ready(function() {
$('#mainNewsBody .news p img').attr("rel", "superbox[image]");
});
$(document).ready(function(){
$('#mainNewsBody .news p img').attr('rel', 'superbox[image]');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.