-
Notifications
You must be signed in to change notification settings - Fork 0
/
all_makeup.js
34 lines (29 loc) · 1.22 KB
/
all_makeup.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
let favArr=JSON.parse(localStorage.getItem("fav"))||[];
for(i=0; i<20; i++){
document.querySelectorAll(".add-btn")[i].addEventListener("click", function(event){
let obj={
img:event.target.parentNode.querySelectorAll("img")[0].src,
name:event.target.parentNode.querySelectorAll("h4")[1].innerText,
price:event.target.parentNode.querySelectorAll("h3 span")[0].innerText
}
favArr.push(obj);
event.target.parentNode.querySelectorAll(".add-btn")[0].style.backgroundColor="red"
localStorage.setItem("fav", JSON.stringify(favArr));
});
}
// quicklook
let quicklookArr=[];
for(i=0; i<20; i++){
document.querySelectorAll("#list>div>img")[i].addEventListener("click", function(event){
let obj={
img:event.target.parentNode.querySelectorAll("img")[0].src,
name:event.target.parentNode.querySelectorAll("h4")[1].innerText,
price:event.target.parentNode.querySelectorAll("h3 span")[0].innerText
}
quicklookArr.push(obj);
console.log(quicklookArr);
window.location.href="quicklook.html"
localStorage.setItem("quicklook", JSON.stringify(quicklookArr));
quicklookArr=[]
});
}