[英]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.