Q:

how to make a button in javascript

//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>
2
<button onclick="Function()">Text</button>
7
<script>
 function myFunction() {
   alert("ALERT");
 }
</script>
<button onclick="myFunction">Click</button>
1
const button = document.createElement("button");
button.innerHTML = "Do Something";
1
<button id="btn">button</button>
0

New to Communities?

Join the community