目标 IE 8 及更低版本将'x-img src'转换回'img src'



我正在使用mobify.js作为我的响应式图像。但是,我必须在我的img src之前添加"x",这样它就会读到"x-img src"。这适用于除 ie 8 及更低版本以外的所有浏览器。

所以我的问题是,有没有办法使用 javascript 将 'x-img src' 标签改回 ie 中的普通 'img src' 标签?

//sets the image source equal to the x-src
element.setAttribute('src',element.getAttribute('x-src'));
//removes x-src
element.removeAttribute('x-src');

最新更新