Adding img to js
2 answers
You can specify the width on this image: (taken from others answer)
var img = document.createElement('img');
img.setAttribute('width', '100%');
document.getElementsByTagName("body")[0].appendChild(img);
Or provide a class name and specify it in CSS:
JavaScript:
var img = document.createElement('img');
img.setAttribute('class', 'wide');
document.getElementsByTagName("body")[0].appendChild(img);
CSS
img.wide {
width:100%;
}
+3
a source to share