-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDOM_Lesson.html
More file actions
127 lines (106 loc) · 4.28 KB
/
DOM_Lesson.html
File metadata and controls
127 lines (106 loc) · 4.28 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document Object Model Lesson</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css"
integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<style>
.dom {
background-image: url("img/the-dom.jpg");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
height: 100vh;
}
</style>
</head>
<body>
<div class="row">
<div class="dom col"></div>
<div class="col">
<h1 class="text-center">The DOM</h1>
<hr class="w-100">
<div class="row">
<div class="col">
<h3 class="headers">Things That Are Important:</h3>
<ol>
<li id="super-important">Family</li>
<li>Action</li>
<li>Speed</li>
<li>Cars</li>
<li>Fury</li>
</ol>
</div>
<div class="col">
<h3 class="headers">Movies</h3>
<ul>
<li>The Fast and the Furious</li>
<li>2 Fast 2 Furious</li>
<li>The Fast and the Furious: Tokyo Drift</li>
<li>Fast & Furious</li>
<li>Fast Five</li>
<li>Fast & Furious 6</li>
<li>Furious 7</li>
<li>The Fate of the Furious</li>
<li id="spin-off">Fast & Furious Presents: Hobbs & Shaw</li>
<li id="unreleased">F9</li>
</ul>
</div>
</div>
<h3 class="headers">My Ride</h3>
<div class="image-container d-flex justify-content-center align-items-center">
<!-- <img id="car-image" src="img/old-car.jpg" alt="Old beat up car">-->
</div>
</div>
</div>
<form name=""fastSurvey method="get">
<label for="answer">What is your favorite movie?</label>
<input type="text" name="answer" id="answer">
</form>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx"
crossorigin="anonymous"></script>
<script>
// Write your code here!
var family = document.getElementById("super-important");
var titles = document.getElementsByClassName("headers");//1
var listItems = document.getElementsByTagName("li");//2
var carImage = document.querySelector("#car-image");
var firstHeaders = document.querySelector('.headers'); // querySelector does not return a collection of items only one.
var allHeaders = document.querySelectorAll('.headers'); // quesrySelectorAll will return a collection of items
// var answer= document.forms.fastSurvey.answer.value;
var mainTitle = document.querySelector('#mainTitle');
//console logs:
console.log(titles[0]);//1
console.log(listItems);//2
console.log((carImage));
console.log(firstHeaders);
console.log(allHeaders);
// console.log(answer);
/// change or modify of elements on arrays:
// titles.forEach(function(header){
// header.style = "font-family: Impact, sans-serif";
// }) !!!forEach LOOP WILL NO WORK LIKE THIS SINCE IS EXPECTING A ARRAYS----
// HTML collections will not have the ability to forEach
for(var i=0; i < titles.length; i++){
console.log("it's working")
titles[i].style= "font-family : Impact, sans-serif";
}
// check for attributes:
carImage.getAttribute('src');// can not be use with list, only single elements
carImage.setAttribute('src', 'img/actual-car.jpg')// change the attribute for a new one
//change value of inner HTML
mainTitle.innerHTML="Hello World";
// we can do this to : mainTitle.innerHTML= "The" <b> DOM <b> lecture;
// mainTitle.innerText = "Hello World';
//
// family.style= "background-color: yellow; color: red; font-weight: bolder;";
var colorChangingBG = setInterval(function(){
})
</script>
</body>
</html>