Answers for "how to make a button with js"

2

how to create a button with javascri[t

// 1. Create the button
var button = document.createElement("button");
button.innerHTML = "Do Something";

// 2. Append somewhere
var body = document.getElementsByTagName("body")[0];
body.appendChild(button);

// 3. Add event handler
button.addEventListener ("click", function() {
  alert("did something");
});

/* Read 

https://css-tricks.com/use-button-element/
*/
Posted by: Guest on April-20-2021
0

css DOM button

--------------------------------------
||| My Entire Code Manage Your Self|||
--------------------------------------

// Part One //
function CreateButton() {

var linkbtn = document.createElement("a");
    linkbtn.innerHTML = "Get Account";
    linkbtn.href = "http://example.com";
    document.body.appendChild(btn);
}
// Part One End //

// Part Two //
var btn = document.createElement("a");
btn.innerHTML = "Get Account";
btn.style.color = "#ffffff";
btn.style.padding = "15px 20px";
btn.style.border = "1px solid #ffffff";
btn.style.backgroundColor = "#307cee";
btn.style.borderRadius = "30px";
btn.href = "http://example.com";
btn.style.textDecoration = "none";
btn.style.display = "inline - block";
btn.style.innerHTML = "Underline Removed";
document.body.appendChild(btn);
// Part Two Start //
Posted by: Guest on December-01-2020

Code answers related to "how to make a button with js"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language