Skip to content

Instantly share code, notes, and snippets.

@EvanGertis
Created February 6, 2019 18:03
Show Gist options
  • Save EvanGertis/f8c2a10c9f185ba4e6d1d3e4010586ae to your computer and use it in GitHub Desktop.
Save EvanGertis/f8c2a10c9f185ba4e6d1d3e4010586ae to your computer and use it in GitHub Desktop.
"use strict"
// select div.
let demoDiv = document.getElementById("demo-div");
// run the function to build the button and
// add it to the html.
buildUI();
function buildUI(){
// create new button and add it to the div.
let button = document.createElement('input');
button.type = "submit";
button.innerHTML= "submit"
button.addEventListener("click", logButton);
demoDiv.appendChild(button)
}
function logButton(){
// log to the console when the button is clicked.
console.log("The button was clicked.")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment