Does anyone know how to make a JavaScript button for an html website?


Punch me in the face if I don't know this, but could you guys help me make a JS button for a website?


buttons are always html, you can dynamicly insert a button with JS or you can execute a js function by adding onclick to button, not sure which one you mean


Well, I was actually asking if you could help me with making one of those input buttons for JS. I think those are onclick. I want a button that anyone can click and execute the script inside the head elements (I am putting internal script into the head element in the html document).


simply put your js code in a function:

var example = function(){
  // your code here


<input type="button" value="click me!" onclick="example()">


Here you can find a few basic examples:


Excellent, thank you, sir.


@stetim94 where would I put the code for html?


in a .html file? I am a bit confused by the question


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.