/
main.js
41 lines (33 loc) · 1.22 KB
/
main.js
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
console.log("Hello animals!");
// Maxence
var $monkey = document.getElementById("monkey")
$monkey.style.color = "chartreuse";
$monkey.innerHTML = $monkey.innerHTML + "!!"
// Mir
document.getElementsByTagName('li')[1].style.color = "blue";
// Noelia
document.getElementsByClassName('ta')[1].style.color = "yellow";
// Tor
document.querySelectorAll('ul .ta')[2].style.color = "purple";
// Silvio
var $li = document.createElement('li')
$li.innerText = "Silvio the Snake"
document.querySelector('ul').appendChild($li)
$li.style.color = "green"
var $tas = document.querySelectorAll('ul .ta')
for (var i = 0; i < $tas.length; i++) {
$tas[i].style.backgroundColor = "orange"
}
// Changing the HREF tag
var $link = document.getElementsByTagName('a')[0]
$link.setAttribute('href', 'https://www.google.de/search?q=monkey&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiHt-jskoHeAhWPKlAKHQ05C7YQ_AUIDigB&biw=447&bih=572&dpr=1.75')
$link.setAttribute('target', 'blank')
// Button
var $button = document.getElementById('add-animal')
$button.onclick = function() {
console.log("You clicked on the button!!")
var $li = document.createElement('li')
$li.innerText = "Andrew the Antilope"
document.querySelector('ul').appendChild($li)
$li.style.color = "pink"
}