Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi..

I am adding image tag from javascript dynamically and trying to call function on onclick event.I have have two images.i want to call same javacript function on onclick of these images from javascript.
Posted

try this
JavaScript
buttonRef.addEventListener("click", function() {
    alert("Blah blah...");
}, false);

Where 'buttonRef' is a reference to button.
 
Share this answer
 
C#
var DownArrow = document.createElement("img");
DownArrow.onclick = function () { return verticlescroll('down'); };

function verticlescroll(arrowDir) {
.......code
}
 
Share this answer
 
Comments
Member 7767265 7-May-17 3:41am    
Very Rare answer to find ... thanks man.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900