Skip to content

Instantly share code, notes, and snippets.

@fyrfli
Created March 14, 2022 08:50
Show Gist options
  • Save fyrfli/1e0e3fba1445eada8e7541af8c061d37 to your computer and use it in GitHub Desktop.
Save fyrfli/1e0e3fba1445eada8e7541af8c061d37 to your computer and use it in GitHub Desktop.
My first JS code
<h1 class="head">Place holder here ... stay tuned!</h1>
<button id="init">Hit me where it tickles!</button>
let initButton = document.getElementById("init");
initButton.onclick = function changeHDG() {
let message = document.querySelector("h1");
let name = undefined;
name = prompt("What is your name?", []);
message.textContent =
name != undefined && name != ""
? "Hello there, " + name + "!"
: "Well, hello anyway!";
};
body {
text-align: center;
margin: 80px auto;
}
#init {
background: violet;
text-align: center;
font-size: 14px;
padding: 10px 20px;
border-radius: 20px;
border: none;
box-shadow: 2px 2px 10px grey;
cursor: click;
transition: transform 0.8s 0.01s;
}
#init:active,
#init:hover {
transform: scale(110%);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment