forked from scottdixon-zz/morning-challenges
-
Notifications
You must be signed in to change notification settings - Fork 0
/
20_welcome.html
49 lines (36 loc) · 1 KB
/
20_welcome.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!--
Run this file in your browser to see what it does.
Your challenge is to:
1. CSS: Give the page a touch of styling. Add some padding to the input box.
2. JS:
a) If the user deletes their name, 'Welcome, ' is still shown. Fix this.
b) Make the user's name show in uppercase.
Hints:
- Just like Ruby, you can check name.value doesn't equal "".
- JS has a helper method for uppercase.
Beast mode:
1. Add another input box, ask for firstname lastname
-->
<!doctype html>
<html>
<head>
<title>Welcome</title>
<style>
body {
text-align: center;
}
</style>
</head>
<body>
<p><input type="text" placeholder="Enter your name"></p>
<h1></h1>
</body>
<script>
const name = document.querySelector('input')
const welcomeMessage = document.querySelector('h1')
name.onkeyup = function () {
// hint: name.value gives you the current text in the input box
welcomeMessage.textContent = `Welcome, ${name.value}!`;
}
</script>
</html>