HTML DOM Image Object
Image Object
The Image object represents the HTML <img> element.
Accessing Image Object
You can use getElementById() to access the <img> element:
var x = document.getElementById("myImg");
Tip:You can also use images Collection Accessing <img> Element
Creating Image Object
You can use the document.createElement() method to create an <img> element:
var x = document.createElement("IMG");
Image Object Properties
Properties | Description |
---|---|
align |
Not supported in HTML5.Please use style.cssFloat. Set or return the value of the image's align attribute. |
alt | Set or return the value of the image's alt attribute. |
border |
Not supported in HTML5.Please use style.border. Set or return the value of the image's border property. |
complete | Return whether the browser has finished loading the image. |
crossOrigin | Set or return the image's CORS settings. |
height | Set or return the value of the image's height property. |
hspace |
Not supported in HTML5.Please use style.margin. Set or return the value of the image's hspace property. |
isMap | Set or return whether the image should be part of the server-side image map. |
longDesc |
Not supported in HTML5. Set or return the value of the image's longdesc attribute. |
lowsrc |
Not supported in HTML5. Set or return the URL of the low-resolution version of the image. |
name |
Not supported in HTML5.Please use id. Set or return the value of the image's name property. |
naturalHeight | Return the original height of the image. |
naturalWidth | Return the original width of the image. |
src | Set or return the value of the image's src property. |
useMap | Set or return the value of the image's usemap property. |
vspace |
Not supported in HTML5.Please use style.margin. Set or return the value of the image's vspace property. |
width | Set or return the value of the image's width property. |
Standard properties and events
The Image object supports both standardPropertiesandEvents.