我正在尝试传递 thesrc
和rel
tag 值。这是示例输入。
<img class="image" src="example.jpg" title="" rel="value" />
以下是一些解析<img>
页面上所有标签的代码。
add: function(src, rel) {
if (this.cache[src]) {
return this.cache[src];
}
if (this.cache[rel]) {
return this.cache[rel];
}
var image = new Image();
image.src = src;
image.rel = rel;
this.setStyle(image, {display: 'block'});
if (image.complete && image.width) {
return image;
}
image.onload = (function(scope) {
return function() {
scope.cache[src] = image;
};
})(this);
jQuery(image).attr('rel', function() { image.rel } );
return image;
},
但是,这是我的输出。
<img src="example.jpg" style="display: block;" />
就好像它完全忽略了rel
标签。我需要将rel
标签值从 old<img>
传递到 new <img>
。