-
Notifications
You must be signed in to change notification settings - Fork 68
/
ecom.js
61 lines (50 loc) · 1.89 KB
/
ecom.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
60
61
const picChange = document.querySelector('.disp');
const opt1 = document.querySelector('.pic1');
const opt2 = document.querySelector('.pic2');
const opt3 = document.querySelector('.pic3');
const opt4 = document.querySelector('.pic4');
let numbo = document.querySelector('.num');
const cart = document.querySelector('.addCart');
const res = document.querySelector('.bugg');
let numb = parseInt(numbo.innerHTML);
const plus = document.querySelector('.pos');
const minus = document.querySelector('.neg');
plus.addEventListener('click',function() {
numbo.innerHTML= numb+1;
console.log(numbo);
})
minus.addEventListener('click', function() {
numbo.innerHTML = (numbo-1);
console.log(numbo);
})
cart.addEventListener('click', function() {
res.setAttribute('class', 'resClick');
})
opt2.addEventListener('click', function() {
picChange.setAttribute("src","images/image-product-2.jpg");
opt2.setAttribute('class','onClick');
opt1.setAttribute('class','opt');
opt3.setAttribute('class','opt');
opt4.setAttribute('class','opt');
})
opt3.addEventListener('click', function() {
picChange.setAttribute("src","images/image-product-3.jpg");
opt3.setAttribute('class','onClick');
opt1.setAttribute('class','opt');
opt2.setAttribute('class','opt');
opt4.setAttribute('class','opt');
})
opt4.addEventListener('click', function() {
picChange.setAttribute("src","images/image-product-4.jpg");
opt4.setAttribute('class','onClick');
opt1.setAttribute('class','opt');
opt2.setAttribute('class','opt');
opt3.setAttribute('class','opt');
})
opt1.addEventListener('click', function() {
picChange.setAttribute("src","images/image-product-1.jpg");
opt1.setAttribute('class','onClick');
opt2.setAttribute('class','opt');
opt3.setAttribute('class','opt');
opt4.setAttribute('class','opt');
})