Repository navigation
Expand file tree
/
Copy pathDOM.js
More file actions
49 lines (39 loc) · 1.6 KB
/
Copy pathDOM.js
File metadata and controls
49 lines (39 loc) · 1.6 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
const alertPlaceholder = document.getElementById('liveAlertPlaceholder')
const appendAlert = (message, type) => {
const wrapper = document.createElement('div')
wrapper.innerHTML = [
`<div class="alert alert-${type} alert-dismissible" role="alert">`,
` <div>${message}</div>`,
' <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>',
'</div>'
].join('')
alertPlaceholder.append(wrapper)
}
const alertTrigger = document.getElementById('liveAlertBtn')
if (alertTrigger) {
alertTrigger.addEventListener('click', () => {
appendAlert('Nice, you triggered this alert message!', 'success')
})
}
// CHANGING THE COLOR OF CARD TITLE
/* let ctitle = document.getElementsByClassName("card-title")[0]
ctitle.style.color = "red" */
/*let ctitle = document.getElementById("alien")
ctitle.style.color = "red" */
/* let ctitles = document.querySelectorAll(".card-title")
ctitles[0].style.color = "green"
ctitles[1].style.color = "yellow"
ctitles[2].style.color = "red" */
/* let ctitle = document.getElementById("alien");
console.log(ctitle);*/
/* let ctitles = document.getElementsByClassName("card-title");
console.log(ctitles); */
let ctitles = document.querySelectorAll(".card-title");
console.log(ctitles);
ctitles[0].style.color = "blue"
ctitles[1].style.color = "red"
ctitles[2].style.color = "yellow"
// QUERY SELECTOR
console.log(document.getElementsByTagName("a"))
console.log(document.querySelector(".card-title").getElementsByTagName("a"))
console.log(document.querySelector(".card").getElementsByTagName("a"))