HTML DOM 이미지 객체
이미지 개체
Image 객체는 HTML <img> 요소를 나타냅니다.
이미지 개체에 액세스
getElementById()를 사용하여 <img> 요소에 액세스할 수 있습니다.
예시
var x = document.getElementById("myImg");
팁: 이미지 컬렉션 을 사용하여 <img> 요소에 액세스할 수도 있습니다 .
이미지 개체 만들기
document.createElement() 메서드를 사용하여 <img> 요소를 만들 수 있습니다.
예시
var x = document.createElement("IMG");
이미지 개체 속성
Property | Description |
---|---|
align | Not supported in HTML5. Use style.cssFloat instead. Sets or returns the value of the align attribute of an image |
alt | Sets or returns the value of the alt attribute of an image |
border | Not supported in HTML5. Use style.border instead. Sets or returns the value of the border attribute of an image |
complete | Returns whether or not the browser is finished loading an image |
crossOrigin | Sets or returns the CORS settings of an image |
height | Sets or returns the value of the height attribute of an image |
hspace | Not supported in HTML5. Use
style.margin instead. Sets or returns the value of the hspace attribute of an image |
isMap | Sets or returns whether an image should be part of a server-side image-map, or not |
longDesc | Not supported in HTML5. Sets or returns the value of the longdesc attribute of an image |
lowsrc | Not supported in HTML5. Sets or returns a URL to a low-resolution version of an image |
name | Not supported in HTML5. Use id instead. Sets or returns the value of the name attribute of an image |
naturalHeight | Returns the original height of an image |
naturalWidth | Returns the original width of an image |
src | Sets or returns the value of the src attribute of an image |
useMap | Sets or returns the value of the usemap attribute of an image |
vspace | Not supported in HTML5. Use
style.margin instead. Sets or returns the value of the vspace attribute of an image |
width | Sets or returns the value of the width attribute of an image |
표준 속성 및 이벤트
Image 객체는 표준 속성 과 이벤트 도 지원합니다 .
관련 페이지
HTML 튜토리얼: HTML 이미지
HTML 참조: HTML <img> 태그