-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathselvaFav.js
59 lines (44 loc) · 1.51 KB
/
selvaFav.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
var favdatas=JSON.parse(localStorage.getItem("favdata"))
console.log(favdatas);
showProducts(favdatas)
function showProducts(event) {
event.map(function (item) {
var imgs = document.createElement("img");
imgs.setAttribute("src", item.image_url);
imgs.setAttribute("id", "imageSizing");
var type = document.createElement("p");
type.textContent = item.type;
type.setAttribute("class", "paraStyle");
var description = document.createElement("p");
description.textContent = item.dsc;
description.setAttribute("class", "paraStyle1");
var x = document.createElement("div");
x.setAttribute("id", "x");
var price = document.createElement("span");
price.textContent = "₹" + item.MRP;
price.setAttribute("class", "pricing");
var disc = document.createElement("span");
disc.textContent = "₹" + item.discount;
disc.setAttribute("id", "discStyle");
var discPer = document.createElement("span");
discPer.textContent = item.discountPercentage;
discPer.setAttribute("id", "discPerStyle");
x.append(price, disc, discPer);
var imgDiv = document.createElement("div");
imgDiv.setAttribute("id", "img");
var btn=document.createElement("button")
btn.setAttribute("class","btnremove")
btn.textContent="Remove";
btn.addEventListener("click",function(){
remove(item)
})
imgDiv.append(imgs, type, description, x,btn);
document.getElementById("images").append(imgDiv);
// imgDiv.append(x);
});
}
function remove(item){
favdatas.splice(item,1)
localStorage.setItem("favdata",JSON.stringify(favdatas))
window.location.reload(true)
}