-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquicklook.js
43 lines (32 loc) · 1.38 KB
/
quicklook.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
42
43
let cartArr=JSON.parse(localStorage.getItem("cart"))||[];
window.onload = function() {
let quicklookArr=JSON.parse(localStorage.getItem("quicklook"))||[]
quicklookArr.forEach(function (el){
let img=document.createElement("img");
img.src=el.img;
let name=document.createElement("h1");
name.innerText=el.name;
let price=document.createElement("h1");
price.innerText="Price: $"+el.price;
let addtocart=document.createElement("button");
addtocart.innerText="Add To Cart"
addtocart.addEventListener("click", function(){
cartArr.push(el);
localStorage.setItem("cart", JSON.stringify(cartArr));
alert("Added To Cart");
history.back();
})
let review=document.createElement("div");
let rev=document.createElement("h2");
rev.innerText="Reviews For the Product"
let rev1=document.createElement("p");
rev1.innerText="Buyer1: ****_ : Awsome product "
let rev2=document.createElement("p");
rev2.innerText="Buyer2: ***** : Must Buy "
let rev3=document.createElement("p");
rev3.innerText="Buyer3: ***__ : Quality Product "
review.append(rev, rev1, rev2, rev3)
document.querySelector("#quicklook").append(img, name, price, addtocart, review);
console.log(el);
})
};