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%");
CodePudding user response:
Already answered here: Setting multiple attributes for an element at once with JavaScript
For jquery, take a look at: https://electrictoolbox.com/jquery-set-multiple-attributes/
CodePudding user response:
$('img').attr({'src':'http://example.com/something.jpeg', 'height':'100%', 'width':'100%'});