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


#1

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


#2

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


#3

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).


#4

simply put your js code in a function:

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

html:

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

#5

Here you can find a few basic examples:


#6

Excellent, thank you, sir.


#7

@stetim94 where would I put the code for html?


#8

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


#9

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