I'm using javascript to create an image element like so:
var img = document.createElement('img');
What would I do to give this img a width of 100%?
You could either specify the width on that image: (taken from others' answer)
var img = document.createElement('img');
img.setAttribute('width', '100%');
document.getElementsByTagName("body")[0].appendChild(img);
Or specify a class name and target it in CSS:
JavaScript:
var img = document.createElement('img');
img.setAttribute('class', 'wide');
document.getElementsByTagName("body")[0].appendChild(img);
CSS:
img.wide {
width:100%;
}