Jump to content

Buttons


mortalc
 Share

Recommended Posts

Set the onclick handler of the "button" (it doesn't have to be a <button>) to run your function.

document.getElementById("button").onclick = function() {	do_maths();}

Link to comment
Share on other sites

Bind the onclick event of the button to a function, which can be done most easily in the button element:<input type="button" onclick="myFunction()" />And then in myFunction() you can do whatever you want to do.Edit: or attach the handler in script as Synook demonstrated, which is considered best practice anyway :)

Edited by chibineku
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...