Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在innerHTML 的img src 开头添加'http:'?图片未正确获取,因为 img src 是这样的“//upload/image.jpg”
提前感谢您提出的任何建议。
src 是 img 标签的一个属性,所以你不会使用 innerHTML。
您可以执行以下操作:
var myImage = document.getElementById('myImage'); myImage.src = 'http:' + myImage.src;