how to make a button in javascript
snippet in html

create javascript button

user9169

const button = document.createElement("button");
button.innerHTML = "Do Something";

javascript buttons

user1214

//Directly taken from https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_pushbutton_create
<body>
<p>Click the "Try it" button to create a BUTTON element with a "Click me" text.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
  var x = document.createElement("BUTTON");
  var t = document.createTextNode("Click me");
  x.appendChild(t);
  document.body.appendChild(x);
}
</script>
</body>

javascript button

user3389

<button onclick="Function()">Text</button>

button functions html

user7407

<script>
 function myFunction() {
   alert("ALERT");
 }
</script>
<button onclick="myFunction">Click</button>

how to make a button in javascript

user5029

<button id="btn">button</button>