HTML DOM Image objekt
Image objekt
The Image object represents the HTML <img> element.
Access Image object
You can use getElementById() to access the <img> element:
var x = document.getElementById("myImg");
Tip:You can also use images collection Access <img> element
Create Image object
You can use the document.createElement() method to create an <img> element:
var x = document.createElement("IMG");
Image object properties
Attributes | Description |
---|---|
align |
Not supported in HTML5.Please use style.cssFloat. Set or return the value of the align attribute of the image. |
alt | Set or return the value of the alt attribute of the image. |
border |
Not supported in HTML5.Please use style.border. Set or return the value of the border attribute of the image. |
complete | Return whether the browser has finished loading the image. |
crossOrigin | Set or return the CORS settings of the image. |
height | Set or return the value of the height attribute of the image. |
hspace |
Not supported in HTML5.Please use style.margin. Set or return the value of the hspace attribute of the image. |
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 longdesc attribute of the image. |
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 name attribute of the image. |
naturalHeight | Return the original height of the image. |
naturalWidth | Return the original width of the image. |
src | Set or return the value of the src attribute of the image. |
useMap | Set or return the value of the usemap attribute of the image. |
vspace |
Not supported in HTML5.Please use style.margin. Set or return the value of the vspace attribute of the image. |
width | Set or return the value of the width attribute of the image. |
Standard attributes and events
The Image object supports both standardAttributesandEvents.