-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblink.js
46 lines (35 loc) · 1.01 KB
/
blink.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
function main(){
var colorClass = "";
$(".select-color").on("click", function(){
var selectedColor = $(this).attr("class");
switch(selectedColor){
case 'select-color cyan not-selected':
colorClass = 'cyan';
// Set color on box div
break;
case 'select-color yellow not-selected':
colorClass = 'yellow';
// Set color on box div
break;
case 'select-color magenta not-selected':
colorClass = 'magenta';
// Set color on box div
break;
}
$(this).removeClass("not-selected");
$(this).siblings().addClass('not-selected');
});
$('.box').on('click', function() {
$(this).toggleClass(colorClass);
});
$('.toggle-blink').on('click', function() {
if (colorClass) {
// the rest of the code in here
$('.toggle-blink').toggleClass('opacity');
setInterval(function() {
$('.box.cyan, .box.yellow, .box.magenta').toggleClass('blink');
}, 350);
};
});
}
$(document).ready(main);