-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
53 lines (43 loc) · 1.34 KB
/
script.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
/*var rating = document.querySelector(".rating"),
ratingItem = document.querySelectorAll(".rating-item");
rating.onclick = function(e) {
var target = e.target;
if (target.classList.contains("rating-item")) {
target.classList.add("active", "current-active");
}
}*/
setTimeout (function(){
alert("Здравствуйте! Хорошего вам дня!");
}, 5000);
var rating = document.querySelector(".rating"),
ratingItem = document.querySelectorAll(".rating-item");
rating.onclick = function(e){
var target = e.target;
if(target.classList.contains("rating-item")){
target.classList.add("active", "current-active");
}
}
rating.onmouseover = function(e) {
var target = e.target;
if(target.classList.contains("rating-item")){
removeClass(ratingItem, "active", "current-active")
target.classList.add("active", "current-active");
mouseOverActiveClass(ratingItem)
}
}
function removeClass(arr) {
for(var i =0, iLen = arr.length; i <iLen; i++) {
for (var j = 1; j < arguments.length; j++) {
ratingItem[i].classList.remove(arguments[j]);
}
}
}
function mouseOverActiveClass(arr){
for(var i = 0, iLen = arr.length; i < iLen; i++){
if(arr[i].classList.contains("active")){
break;
} else {
arr[i].classList.add("active");
}
}
}