Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

Image

Image Element constructor

Accepts two optional parameters: Image([unsigned long width, unsigned long height])

Example:

var myImage = new Image(100, 200);
myImage.src = 'picture.jpg';
console.log(myImage);
Result:
<img width="100" height="200" src="picture.jpg">

 

Note: this constructor exists for historical reasons only and returns an HTMLImageElement instance just as document.createElement('img') would.

 

Document Tags and Contributors

 Last updated by: teoli,