0

クライアントがいくつかのページスニペットをレンダリングするために使用する、残りの 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を使用してこれを達成するにはどうすればよいですか?

みんな、ありがとう。

4

3 に答える 3

1
$(function(){
 $('#mainNewsBody .news img').attr('rel', 'superbox[image]');
});
于 2013-02-06T16:11:02.103 に答える
0
$(document).ready(function(){
    $('#mainNewsBody .news p img').attr('rel', 'superbox[image]');
});
于 2013-02-06T16:11:40.110 に答える
0
$(document).ready(function() {

    $('#mainNewsBody .news p img').attr("rel", "superbox[image]");

});
于 2013-02-06T16:11:34.307 に答える