This time, the small case is as titled, and there is an additional one that responds to the event when clicking on the image. The code is as follows:
The code copy is as follows:
<script type="text/javascript">
function 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(){ //Respond to event when clicking
alert("click");
//window.location = "http://baidu.com"; Jump url
};
_td.appendChild(_img);
}
</script>
Just call the above function in the onload event in the body.