forked from iamshaunjp/JavaScript-DOM-Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
56 lines (39 loc) · 1.21 KB
/
app.js
File metadata and controls
56 lines (39 loc) · 1.21 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
let titles = document.getElementsByClassName('title');
console.log(Array.isArray(titles));
console.log(Array.isArray(Array.from(titles)));
console.log(Array.from(titles));
console.log([titles]);
// titles.forEach((title) => console.log(title));
// const titles = document.getElementsByClassName('title');
//
// console.log(Array.isArray(titles));
// console.log(Array.isArray(Array.from(titles)));
//
// Array.from(titles).forEach(function(title){
// console.log(title);
// });
let title = document.querySelector('#button');
title.addEventListener('click', (event) => {
event.preventDefault();
let newDiv = document.createElement('div');
newDiv.textContent = 'Hi im a div!';
document.body.appendChild(newDiv);
})
title.addEventListener('mouseover', () => {
title.style.backgroundColor = 'yellow';
})
title.addEventListener('mouseout', () => {
title.style.backgroundColor = '';
})
document.body.addEventListener('mouseover', (event) => {
// console.log(event.target)
event.target.style.backgroundColor = 'blue';
})
document.body.addEventListener('mouseout', (event) => {
// console.log(event.target)
event.target.style.backgroundColor = 'yellow';
})
function f(x) {
x*=2;
return function )()
}