forked from codemistic/Web-Development
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounter.js
More file actions
29 lines (28 loc) · 684 Bytes
/
Counter.js
File metadata and controls
29 lines (28 loc) · 684 Bytes
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
var $increase = $('#increase');
var $decrease = $('#decrease');
var $reset = $('#reset');
var $number = $('#number');
var i = 0;
$increase.on('click', function () {
i += 1;
$number.text(i);
});
$decrease.on('click', function () {
i -= 1;
$number.text(i);
});
$reset.on('click', function () {
i = 0;
$number.text(i);
});
$('input').on('mouseover click', function () {
$(this).css({ 'background-color': getRandomColor(), transition: '1s', 'border-color': getRandomColor() });
});
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}