이번에는 작은 케이스의 제목이 있으며 이미지를 클릭 할 때 이벤트에 응답하는 추가가 있습니다. 코드는 다음과 같습니다.
코드 사본은 다음과 같습니다.
<script type = "text/javaScript">
함수 onloadevent () {
var _td = document.getElementById ( "a1");
var _img = document.createElement ( "IMG");
_img.setattribute ( "id", "floatimage");
_img.setattribute ( "src", "icon.png");
_img.setattribute ( "onclick", "clickImage ()");
_img.onclick = function () {// 클릭 할 때 이벤트에 응답합니다
경고 ( "클릭");
//window.location = "http://baidu.com"; 점프 URL
};
_td.appendChild (_img);
}
</스크립트>
본문의 온부하 이벤트에서 위의 기능을 호출하십시오.