-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
10 lines (9 loc) · 827 Bytes
/
script.js
File metadata and controls
10 lines (9 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
// Get the value of the name input from the form and update the greeting
const greetingText = document.querySelector("#greeting"); // get greeting element
const inputElement = document.querySelector("#exampleFormControlInput1"); // get input element
const btn = document.querySelector("#exampleFormBtn"); // get the element with id = 'exampleFormBtn'
btn.addEventListener("click", function () {
// add an event to the button: whenever the button is pressed, update the greeting name
// CHALLENGE step 3 of 3: JS. In the next line change the word Hello to another greeting word. Save the file. Type a name in the box. Click Submit.
greetingText.innerHTML = `Hello, ${inputElement.value}`; // this is a templated string in Javscript! https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
});