0
Can I put a function in a function and use the one inside for onclick?
3 odpowiedzi
+ 2
Yes Ipang is right.
You can just set the onclick inside the func.
Ex:-
...
btn.onclick=function(){
...
}
+ 3
If you encapsulate an event handler, it would be better if you map the event to its handling function using addEventListener( ).
If you mapped the event using HTML element's 'onclick' attribute, the event handler must not be encapsulated e.g. in global space.