-
Notifications
You must be signed in to change notification settings - Fork 0
/
09-dom.html
45 lines (31 loc) · 1.08 KB
/
09-dom.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
<!DOCTYPE html>
<head>
<title>DOM</title>
</head>
<body>
<button> Hello </button>
<button class="js-button"> Second Button</button>
<script>
// when HTML element is inside JavaScript it is just a javascript Object.
console.log(document.querySelector('button').innerHTML);
document.querySelector('button')
.innerHTML = 'changed';
const buttonElement = document.querySelector('.js-button');
// using the DOM we can get HTML elements from the page put it inside JavaScript and save it in a variable.
// The DOM combines JS and HTML AND gives full cpntrol of the webpage
console.log(buttonElement);
/*
console.log(document.title);
document.title = 'changed';
console.log(document.body);
console.log(typeof document.body);
console.log(document.body.innerHTML);
document.body.innerHTML = '<button> Good Job!</button>';
*/
/*
document.body.innerHTML = 'Hello';
document.title = 'Good Job!';
*/
</script>
</body>
</html>