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