加速移动页面(AMP)项目
原版的
<div class="thumbnail">
<img src="MyImage.jpg" alt="an image"/>
</div>
结果
<div class="thumbnail">
<amp-img src="MyImage.jpg" width="1080" height="610" layout="responsive" alt="an image"></amp-img>
</div>
如何使用jQuery?
使用.replaceWith()
API替换内容:
$('.thumbnail').find('img').replaceWith(function () {
return '<amp-img src="'+this.src+'" width="1080" height="610" layout="responsive" alt="'+this.alt+'"></amp-img>'
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句