forked from shreymishra27/Unit-2-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deals.html
549 lines (521 loc) · 19.6 KB
/
deals.html
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="common.css" />
</head>
<body>
<div class="nav">
<div class="guest">
<a href="guest.html"> <h1>Guest Services</h1></a>
</div>
<div class="logo" onclick="window.location.href='index.html'">
<img
src="https://shopdisney.in/media/logo/stores/1/shopDisney_1.png"
alt=""
/>
</div>
<div class="nav-right">
<div class="sign">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
<path
d="M224 256c70.7 0 128-57.31 128-128s-57.3-128-128-128C153.3 0 96 57.31 96 128S153.3 256 224 256zM274.7 304H173.3C77.61 304 0 381.6 0 477.3c0 19.14 15.52 34.67 34.66 34.67h378.7C432.5 512 448 496.5 448 477.3C448 381.6 370.4 304 274.7 304z"
/>
</svg>
<span id="para">Hi Shrey!</span>
</div>
<div class="wishList">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<!--! Font Awesome Pro 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. -->
<path
d="M0 190.9V185.1C0 115.2 50.52 55.58 119.4 44.1C164.1 36.51 211.4 51.37 244 84.02L256 96L267.1 84.02C300.6 51.37 347 36.51 392.6 44.1C461.5 55.58 512 115.2 512 185.1V190.9C512 232.4 494.8 272.1 464.4 300.4L283.7 469.1C276.2 476.1 266.3 480 256 480C245.7 480 235.8 476.1 228.3 469.1L47.59 300.4C17.23 272.1 .0003 232.4 .0003 190.9L0 190.9z"
/>
</svg>
<a href="">My Wishlist</a>
</div>
<div class="cart">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
<!--! Font Awesome Pro 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. -->
<path
d="M112 112C112 50.14 162.1 0 224 0C285.9 0 336 50.14 336 112V160H400C426.5 160 448 181.5 448 208V416C448 469 405 512 352 512H96C42.98 512 0 469 0 416V208C0 181.5 21.49 160 48 160H112V112zM160 160H288V112C288 76.65 259.3 48 224 48C188.7 48 160 76.65 160 112V160zM136 256C149.3 256 160 245.3 160 232C160 218.7 149.3 208 136 208C122.7 208 112 218.7 112 232C112 245.3 122.7 256 136 256zM312 208C298.7 208 288 218.7 288 232C288 245.3 298.7 256 312 256C325.3 256 336 245.3 336 232C336 218.7 325.3 208 312 208z"
/>
</svg>
<a href="">My Bag</a>
</div>
</div>
</div>
<br />
<div class="nav-2">
<div class="sale">
<a href="deals.html"><h1>NEW</h1></a>
<h1>|</h1>
<a href="deals.html"><h1>SALE</h1></a>
</div>
<div class="opt">
<a href="gifts.html"><h1>GIFTS</h1></a>
<a href="fashion.html"><h1>FASHION AND ACCESSORIES</h1></a>
<a href="toys.html"><h1>TOYS</h1></a>
<a href="backtoschool.html"> <h1>BACK TO SCHOOL</h1></a>
<a href="afterSign.html"><h1>HOME</h1></a>
<a href="gadgets.html"><h1>GADGETS</h1></a>
</div>
<div class="search-container">
<input type="text" class="search-box" placeholder="Search..." />
<button class="search-button">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<!--! Font Awesome Pro 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. -->
<path
d="M500.3 443.7l-119.7-119.7c27.22-40.41 40.65-90.9 33.46-144.7C401.8 87.79 326.8 13.32 235.2 1.723C99.01-15.51-15.51 99.01 1.724 235.2c11.6 91.64 86.08 166.7 177.6 178.9c53.8 7.189 104.3-6.236 144.7-33.46l119.7 119.7c15.62 15.62 40.95 15.62 56.57 0C515.9 484.7 515.9 459.3 500.3 443.7zM79.1 208c0-70.58 57.42-128 128-128s128 57.42 128 128c0 70.58-57.42 128-128 128S79.1 278.6 79.1 208z"
/>
</svg>
</button>
</div>
</div>
<div id="pic">
<img
src="https://shopdisney.in/media/March/2022/banner/d_Fashion-Accessories.jpg"
alt=""
/>
</div>
<div id="text">
<p>ShopDisney / Fashion & Accessories</p>
</div>
<div id="flex">
<div id="filter">
<select id="sortNames" onchange="handleNameSort()">
<option value="">Sort By Names</option>
<option value="ascending">Ascending</option>
<option value="descending">Descending</option>
</select>
<br />
<select
name="Sort by price"
id="sortprice"
onchange="handlePriceSort()"
>
<option value="">Sort By Price</option>
<option value="htl">High To Low</option>
<option value="lth">Low To High</option>
</select>
<!-- <select id="filtercat" onchange="handleCatSort()">
<option value="">Filter by catagery</option>
<option value="Hoodie">Hoodie</option>
<option value="Shoes">Foot Wear</option>
<option value="T-Shirts">T-shirt</option>
</select> -->
</div>
<div id="grid"></div>
</div>
</body>
</html>
<script>
cartdata = JSON.parse(localStorage.getItem("cart")) || [];
dealsdata = [
{
Image:
"https://shopdisney.in/media/catalog/product/9/0/903671140103-1.jpg?width=300&height=&canvas=300,&quality=80&bg-color=255,255,255&fit=bounds",
Name: "Marvel Avengers Endgame Hulk (Deluxe Version)",
Strikeoffprice: 20000,
Price: 19699,
// Catagery:""
},
{
Image:
"https://shopdisney.in/media/catalog/product/l/b/lbdp50009.jpg?width=300&height=&canvas=300,&quality=80&bg-color=255,255,255&fit=bounds",
Name: "Disney Frozen MDF Kristoff and Sven with Base",
Strikeoffprice: 999,
Price: 499,
// Catagery:""
},
{
Image:
"https://shopdisney.in/media/catalog/product/d/m/dmzcb_7_1.jpg?width=300&height=&canvas=300,&quality=80&bg-color=255,255,255&fit=bounds",
Name: "Marvel Avengers Domez Collection Combo Pack of 3",
Strikeoffprice: 2000,
Price: 1497,
// Catagery:""
},
{
Image:
"https://shopdisney.in/media/catalog/product/f/u/fu39209_-_molten_man.1.jpg?width=300&height=&canvas=300,&quality=80&bg-color=255,255,255&fit=bounds",
Name: "Marvel Spiderman Far From Home Molten Man 4 Inch",
Strikeoffprice: 999,
Price: 499,
// Catagery:""
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/m/m/mmfwct032.9_1_6.jpg",
Name: "Disney Mickey Mouse T-shirt Sky Blue For Women",
Strikeoffprice: 1395,
Price: 446,
Catagery: "T-shirt",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/m/m/mmfwct032.6_1_6.jpg",
Name: "Disney Mickey Mouse T-shirt Pink For Women",
Strikeoffprice: 1395,
Price: 446,
Catagery: "T-shirt",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/m/m/mmfwct032.2_1_6.jpg",
Name: "Disney Mickey Mouse T-shirt Black For Women",
Strikeoffprice: 1395,
Price: 446,
Catagery: "T-shirt",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/m/m/mmfwct032.22_1_6.jpg",
Name: "Disney Mickey Mouse T-shirt Yellow For Women",
Strikeoffprice: 1395,
Price: 446,
Catagery: "T-shirt",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001766_1_2.jpg",
Name: "Marvel Spider-Man Grey Sweatshirt",
Strikeoffprice: 2199.0,
Price: 880.0,
Catagery: "T-shirt",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001735_1_2.jpg",
Name: "Marvel Spider-Man No Way Home Tshirt",
Strikeoffprice: 699.0,
Price: 594.0,
Catagery: "T-shirt",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001762_1_2.jpg",
Name: "Marvel Spider-Man Black Sweatshirt",
Strikeoffprice: 2199.0,
Price: 880.0,
Catagery: "T-shirt",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001739_1_2.jpg",
Name: "Marvel Spider-Man No Way Home Tshirt",
Strikeoffprice: 799.0,
Price: 679.0,
Catagery: "T-shirt",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001734_1_2.jpg",
Name: "Marvel Spider-Man No Way Home White Tshirt",
Strikeoffprice: 599.0,
Price: 509.0,
Catagery: "T-shirt",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/d/d/ddm-1988-288-ptd.jpg",
Name: "Disney Princess Dream Mug Multicolor",
Strikeoffprice: 299,
Price: 199,
// Catagery:""
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/d/i/disney_minnie_speed_stainless_steel_bottle_650_ml_1.png",
Name: "Disney Minnie Mouse Speed Stainless Steel Bottle, 650 ML Pink",
Strikeoffprice: 499,
Price: 425,
// Catagery:""
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/d/i/disney_minnie_pluto_stainless_steel_bottle_800_ml_1.png",
Name: "Disney Minnie Mouse Pluto Stainless Steel",
Strikeoffprice: 649,
Price: 520,
// Catagery:""
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/d/i/disney_minnie_pluto_stainless_steel_bottle_600_ml_1.png",
Name: "Disney Mickey Mouse Pluto Stainless Steel ",
Strikeoffprice: 549,
Price: 467,
// Catagery:""
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/d/i/disney_mickey_pluto_stainless_steel_bottle_600_ml_1.png",
Name: "Disney Minnie Mouse Pluto Stainless Steel",
Strikeoffprice: 549,
Price: 467,
// Catagery:""
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/d/i/disney_minnie_fizzy_stainless_steel_bottle_800_ml_1.png",
Name: "Disney Mickey Mouse Pluto Stainless Steel ",
Strikeoffprice: 599,
Price: 480,
// Catagery:""
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/d/i/disney_princess_kiddo_stainless_steel_insulated_bottle_500_ml_1_1.jpg",
Name: "Disney Princess Kiddo Stainless Steel ",
Strikeoffprice: 912,
Price: 776,
// Catagery:""
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/m/c/mcdmopdpublicenemyspidey1.jpg",
Name: "Marvel Spider-Man Public Enemy - Mouse Pad Multicolor For Unisex",
Strikeoffprice: 499,
Price: 399,
Catagery: "Mouse Pad",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/m/c/mcdmopdpeterparkergrunge1.jpg",
Name: "Marvel Spider-Man Peter Parker Grunge - Mouse Pad Multicolor For Unisex",
Strikeoffprice: 499,
Price: 399,
Catagery: "Mouse Pad",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/m/c/mcdmopdpeterblackandgold1.jpg",
Name: "Marvel Spider-Man Peter Black and Gold - Mouse Pad Multicolor For Unisex",
Strikeoffprice: 499,
Price: 399,
Catagery: "Mouse Pad",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/m/c/mcdmopdnowayhomespidey1.jpg",
Name: "Marvel Spider-Man No Way Home - Mouse Pad Multicolor For Unisex",
Strikeoffprice: 499,
Price: 399,
Catagery: "Mouse Pad",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/m/c/mcdmopdnewspidertech1.jpg",
Name: "Marvel Spider-Man New Tech - Mouse Pad Multicolor For Unisex",
Strikeoffprice: 499,
Price: 399,
Catagery: "Mouse Pad",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/m/c/mcdmopdneighborhoodspidey1.jpg",
Name: "Marvel Spider-Man Neighborhood - Mouse Pad Multicolor For Unisex",
Strikeoffprice: 499,
Price: 399,
Catagery: "Mouse Pad",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/m/c/mcdmopdmysticartsspidey1.jpg",
Name: "Marvel Spider-Man Mystic Arts - Mouse Pad Multicolor For Unisex",
Strikeoffprice: 499,
Price: 399,
Catagery: "Mouse Pad",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/m/c/mcdmopdintegratedspiderlogo1.jpg",
Name: "Marvel Spider-Man Integrated Logo - Mouse Pad Multicolor For Unisex",
Strikeoffprice: 499,
Price: 399,
Catagery: "Mouse Pad",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/m/c/mcdmopdextraordinaryspiderman1.jpg",
Name: "Marvel Spider-Man Extraordinary man - Mouse Pad Multicolor For Unisex",
Strikeoffprice: 499,
Price: 399,
Catagery: "Mouse Pad",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/m/c/mcdmopdall3spidey1.jpg",
Name: "Marvel Spider-Man All 3 - Mouse Pad Multicolor For Unisex",
Strikeoffprice: 499,
Price: 399,
Catagery: "Mouse Pad",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/d/i/disney_minnie_kiddo_stainless_steel_insulated_bottle_500_ml_1.jpg",
Name: "Disney Minnie Mouse Kiddo Stainless Steel ",
Strikeoffprice: 912,
Price: 776,
// Catagery:""
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001738_1_2.jpg",
Name: "Marvel Spider-Man No Way Home Black Tshir",
Strikeoffprice: 699.0,
Price: 594.0,
Catagery: "T-shirt",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-001731_1_2.jpg",
Name: "Marvel Spider-Man No Way Home Red Tshirt",
Strikeoffprice: 699.0,
Price: 594.0,
Catagery: "T-shirt",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/m/m/mmfwct032.1_1_6.jpg",
Name: "Disney Mickey Mouse T-shirt White For Women",
Strikeoffprice: 1395,
Price: 446,
Catagery: "T-shirt",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/m/m/mmewct004.9_1_6.jpg",
Name: "Disney Minnie Mouse T-shirt Sky Blue For Women",
Strikeoffprice: 1395,
Price: 446,
Catagery: "T-shirt",
},
{
Image:
"https://shopdisney.in/media/catalog/product/s/p/sportscombopack_1.jpg?width=300&height=&canvas=300,&quality=80&bg-color=255,255,255&fit=bounds",
Name: "Marvel Spiderman 4 in 1 Mega Sports Combo ",
Strikeoffprice: 1999,
Price: 1499,
// Catagery:""
},
{
Image:
"https://shopdisney.in/media/catalog/product/f/u/fu36342.1.jpg?width=300&height=&canvas=300,&quality=80&bg-color=255,255,255&fit=bounds",
Name: "Marvel: Captain Marvel - Vers 4 Inch Pop By Funko",
Strikeoffprice: 1499,
Price: 1099,
// Catagery:""
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-002277_1_1.jpg",
Name: "Marvel Spider-Man Off White Tshirt For Men",
Strikeoffprice: 1399.0,
Price: 630.0,
Catagery: "T-shirt",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-002276_1_1.jpg",
Name: "Marvel Spider-Man Black Tshirt For Men",
Strikeoffprice: 1299.0,
Price: 585.0,
Catagery: "T-shirt",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-002275_1_1.jpg",
Name: "Marvel Spider-Man Grey Tshirt For Men",
Strikeoffprice: 1299.0,
Price: 585.0,
Catagery: "T-shirt",
},
{
Image:
"https://shopdisney.in/media/catalog/product/cache/653b84d7c049b572e5becd44f2ff8080/s/t/sty-21-22-002274_1_1.jpg",
Name: "Marvel Spider-Man Grey Tshirt For Me",
Strikeoffprice: 1399.0,
Price: 630.0,
Catagery: "T-shirt",
},
];
displayData(dealsdata);
function handlePriceSort() {
console.log("YES");
var sort = document.querySelector("#sortprice").value;
if (sort == "htl") {
dealsdata.sort(function (a, b) {
return b.Price - a.Price;
});
displayData(dealsdata);
}
if (sort == "lth") {
fashiondata.sort(function (a, b) {
return a.Price - b.Price;
});
displayData(dealsdata);
}
}
function handleNameSort() {
// console.log("Yes")
var sort = document.querySelector("#sortNames").value;
// console.log(sort)
if (sort == "ascending") {
fashiondata.sort(function (a, b) {
if (a.Name > b.Name) return 1;
if (a.Name < b.Name) return -1;
return 0;
});
console.log("Yes");
displayData(dealsdata);
}
if (sort == "descending") {
fashiondata.sort(function (a, b) {
if (a.Name > b.Name) return -1;
if (a.Name < b.Name) return 1;
return 0;
});
console.log("NOO");
displayData(dealsdata);
}
}
function displayData(dealsdata) {
document.querySelector("#grid").innerHTML = "";
dealsdata.map(function (elem) {
var maindiv = document.createElement("div");
maindiv.setAttribute("id", "maindiv");
var div1 = document.createElement("div");
var image = document.createElement("img");
image.src = elem.Image;
image.setAttribute("id", "img");
var name = document.createElement("p");
name.innerText = elem.Name;
div1.append(image, name);
var pricediv = document.createElement("div");
pricediv.setAttribute("id", "pricediv");
var strprice = document.createElement("p");
strprice.innerText = "₹" + " " + elem.Strikeoffprice;
strprice.setAttribute("id", "strike");
var price = document.createElement("P");
price.innerText = "₹" + " " + elem.Price;
var cart = document.createElement("button");
cart.innerText = "Add to cart";
cart.setAttribute("id", "btn");
cart.addEventListener("click", function () {
cartfun(elem);
});
pricediv.append(strprice, price);
maindiv.append(div1, pricediv, cart);
document.querySelector("#grid").append(maindiv);
});
}
function cartfun(elem) {
cartdata.push(elem);
localStorage.setItem("cart", JSON.stringify(cartdata));
alert("Item added to cart");
console.log(cartdata);
}
</script>