-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
52 lines (46 loc) · 1.13 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
$(document).ready(function () {
var counter = 1;
$("#addButton").click(function () {
var newButtonDiv = $(document.createElement("div")).attr(
"id",
"NewButton" + counter
);
let divTag = newButtonDiv.html(
" </label>" +
'<input type="button" name="' +
counter +
'" id="button' +
counter +
'" value="' +
counter +
'" style="background-color: blue; color: white' +
'" >'
);
if (counter % 2 == 0) {
let v = divTag[0];
v.getElementsByTagName("input")[0].style.backgroundColor = "black";
}
if (counter % 5 == 0) {
let c = divTag[0];
c.getElementsByTagName("input")[0].style.borderTop = "5px solid Orange";
}
newButtonDiv.appendTo("#ButtonsGroup");
document.getElementById("count").innerHTML = +counter;
counter++;
});
$("#removeButton").click(function () {
if (counter == 2) {
$("#NewButton1").remove();
document.getElementById("count").innerHTML = "No Boxes";
counter = 1;
return;
} else {
if (counter > 2) {
counter--;
$("#NewButton" + counter).remove();
document.getElementById("count").innerHTML = counter - 1;
}
}
return false;
});
});