-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
69 lines (42 loc) · 1.65 KB
/
main.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
62
63
64
65
66
67
68
69
/* btnP, btnM, btnZ go to the html and search the (#plus, #minus, #zero => ID's buttons and put inside the strings ) also count get the 0 number, and paragraph get p => the p tag <p> */
let btnP = document.querySelector('#plus');
let btnM = document.querySelector('#minus');
let btnZ = document.querySelector('#zero');
let count = 0;
let paragraph = document.querySelector('p');
/* pluse - incriment (to add more), text that i choose, to anderstand what will the function will do.
count is the text that will get in to him the calculation, than in the <p> at the HTML, */
function increment() {
count += 1; //add number
paragraph.innerHTML="This is the counter number: "+count
};
// get call the function to run, and add number if the user click on the '+' icon
btnP.onclick = increment;
// minus
function decrement(url) {
count -= 1; //minus number
paragraph.innerHTML="This is the counter number: "+count
};
btnM.onclick = decrement;
// zero - function called zero get count 0 and in the <p> in the HTML text + get in to the count string the new number here Clear to 0
function zero() {
count = 0; //clear number
paragraph.innerHTML="This is the counter number: "+count
};
btnZ.onclick = zero; // if you click on the button it will zeroed the number of counting
/*
var button = document.querySelector('button'),
count = 0;
button.onclick = function() {
count += 1;
button.innerHTML = "p" + count;
};
*/
// var btn = document.querySelector('button'),
// count = 0;
// var paragraph = document.querySelector('p');
// function increment() {
// count += 1;
// alert(paragraph.innerHTML)
// };
// btn.onclick = increment;