-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
62 lines (56 loc) · 1.87 KB
/
index.html
File metadata and controls
62 lines (56 loc) · 1.87 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="parent">
<label for="text1"></label>
<input type="text" id="text1">
<button id="button1">BUTTON</button>
</div>
<script>
console.log('Hello console! - line 13');
//Enter or type in text box
const inputElement = document.getElementById('text1');
console.log(inputElement);
const buttonElement = document.getElementById('button1');
console.log(buttonElement);
inputElement.addEventListener('change', function(e){
console.log(`CHANGE: The value you entered is ${e.target.value}`);
});
inputElement.addEventListener('input', function(e){
console.log(`INPUT: The value you just typed is ${e.target.value}`);
});
//Click button and parent div
const parentElement = document.getElementById('parent');
buttonElement.addEventListener('click', function(e){
console.log('You clicked on the button!');
e.stopPropagation();
});
parentElement.addEventListener('click', function(){
console.log('You clicked on the parent containing div.');
});
//Mouseover & Mouseout
buttonElement.addEventListener('mouseover', function(){
console.log('Your mouse is on the button');
});
buttonElement.addEventListener('mouseout', function(){
console.log('Your mouse is no longer on the button');
});
//Focus and blur
inputElement.addEventListener('focus', function(){
console.log('You focused on the input!');
});
inputElement.addEventListener('blur', function(){
console.log('You stopped focusing on the input!');
});
//Keydown
document.addEventListener('keydown', function(){
console.log(`You just hit the ${e.key} key`);
});
</script>
</body>
</html>