Computer >> Computer tutorials >  >> Programming >> Javascript

How to use an HTML button to call a JavaScript function?


The simplest way to use an HTML button to call a JavaScript function is shown below −

<input id = "Double Click here" type = "button" value = "clickme" ondblclick = "myFunction();" />

You can also use the following by adding to the DOM property −

document.getElementById("Double Click here ").ondblclick = myFunction;