-3

I am trying to make a JavaScript game and I am trying to add a button but I am not sure how to so I tried googling it but I am only getting html buttons which is not what I am looking for. I am only using html to show the canvas that was made in js. Is it even possible to make a button in js by itself?

  • In your own words, what is a _"JavaScript button"_ and how does it differ to the HTML ` – Phil Aug 03 '18 at 01:44
  • 2
    Take a look at this answer, should help you out. https://stackoverflow.com/a/24384882/2880747 – WilomGfx Aug 03 '18 at 01:50

1 Answers1

1

You want to do something like this:

var button = document.createElement("button");

...and then you'll have to append it to the DOM. Read the full documentation here:

https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement

hcs
  • 321
  • 3
  • 14