0
How to change the onclick property of an html element with JavaScript?
I am making a calculator and I want to change the onClick function, when we click any other element.
2 Réponses
+ 5
Get the element reference, for example:
var eref = document.getElementById('myElementID');
... and use its .addEventListener() method:
e.ref.addEventListener('click', function() { /* code */ });
Obviously, you can provide a function name already declared ;)
0
thanks man