I want to do this using jQuery at once.
var elem = document.createElement("img");
elem.setAttribute("src", "http://example.com/something.jpeg");
elem.setAttribute("height", "100%");
elem.setAttribute("width", "100%");
$('img').attr({'src':'http://example.com/something.jpeg', 'height':'100%', 'width':'100%'});
$('img') <= coresponding HTML element which you want to set the attributes
.attr(
{
'htmlAttributeName': 'attributeValue',
'anotherHtmlAttributeName': 'attributeValue',
....
}
)
.attrpage: api.jquery.com/attr Setting several attributes at once