-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyFourthDom.txt
33 lines (26 loc) · 961 Bytes
/
MyFourthDom.txt
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
// querySelector & querySelectorAll Methods:
let Selector = document.querySelector("#main-heading");
Selector.style.textAllign= "right";
let main = document.querySelector("#basket-heading");
main.style.color= "brown";
main.style.marginLeft ='30px';
let fruit = document.querySelector(".fruits");
fruit.style.backgroundColor ="gray";
fruit.style.padding="30px";
fruit.style.margin ="30px";
fruit.style.width ="50px";
fruit.style.borderRadius="5px";
fruit.style.listStyleType="none";
let fruits = document.querySelectorAll(".fruit");
for(let i=0;i<fruits.length;i++){
fruits[i].style.backgroundColor ="lightgray";
fruits[i].style.padding="10px";
fruits[i].style.margin ="10px";
fruits[i].style.borderRadius="5px";
fruits[i].style.color ="black"
}
let Oddfruits = document.querySelectorAll(".fruit:nth-child(even)");
for(let i=0;i<Oddfruits.length;i++){
Oddfruits[i].style.backgroundColor ="red";
Oddfruits[i].style.color ="white"
}