?이입력 유형 = 'file'이 (가) 이벤트를 전달하지 않는 이유는 무엇입니까? 이 간단한 예제가 작동하지 않는 이유는
<input id="image" type="file"/>
<img src='https://cdn.elegantthemes.com/blog/wp-content/uploads/2015/02/custom-trackable-short-url-feature.png' onclick='imageLoad()'></img>
<script>
function imageLoad() {
let ev = new Event('click', {bubbles: true});
image.dispatchEvent(ev);
}
</script>
"작동하지 않음"을 정의하십시오. 'image'는 정의되어 있지 않습니다. 콘솔이 아마 –
을 말하고있을 것입니다. 또한'img'는 [* void element *] (https://www.w3.org/TR/html5/syntax.html#void-elements)입니다.), 절대로 닫는 태그가 없습니다. ''을 쓰지 마십시오. HTML에서는 단지 '
'입니다. XHTML에서 (아마 사용하지 않을 것입니다), 그것은 '
'입니다. –
@JeremyThille : 안타깝게도,'image'는 정의되어 있지 않습니다.'id'가 있기 때문에 파일 입력을위한 자동 전역입니다. : - | –