image - How to change img to amp-img with jQuery? -


accelerated mobile pages (amp) project

original

<div class="thumbnail">   <img src="myimage.jpg" alt="an image"/> </div> 

result

<div class="thumbnail">  <amp-img src="myimage.jpg" width="1080" height="610" layout="responsive" alt="an image"></amp-img> </div> 

how jquery ?

use .replacewith() api replace content :

$('.thumbnail').find('img').replacewith(function () {    return '<amp-img src="'+this.src+'" width="1080" height="610" layout="responsive" alt="'+this.alt+'"></amp-img>' }); 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -