How to add onclick to a html element dynamically using javascript -


i able create button element , add onclick event shown below.

elem.onclick=function() { alert("qweqweqwe"); }         

how go using predefined function instead of defining function inside of event? like:

elem.onclick=func(); 

add eventlistener element has defined function call :

elem.addeventlistener("click", func, false); //where func function name 

Comments

Popular posts from this blog

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -