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

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -