且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何添加由动态生成的图像的javascript函数onclick事件

更新时间:2023-12-05 23:37:52

试试这个
buttonRef.addEventListener("click", function() {
    alert("Blah blah...");
}, false);


其中"buttonRef"是对按钮的引用.


Where ''buttonRef'' is a reference to button.


var DownArrow = document.createElement("img");
DownArrow.onclick = function () { return verticlescroll('down'); };

function verticlescroll(arrowDir) {
.......code
}