-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
36 lines (32 loc) · 1.05 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
$(function(){
const ratingButtons = [...$(".ratingButton")];
let isRatingClicked = false;
let ratingVal;
ratingButtons.forEach(button =>{
button.addEventListener('click', raingClicked);
})
function raingClicked(event){
$('.ratingButton').attr('class', 'ratingButton');
let currentRatingSelected = event.target;
$(currentRatingSelected).addClass('ratingButtonSelected');
isRatingClicked = true;
ratingVal = ($(currentRatingSelected).text());
}
$( ".submitButton" ).click(function() {
if(isRatingClicked == false){
shakeElement(this);
}else{
$('#ratingValueTxt').text('You selected '+ ratingVal +' out of 5');
$('.containerMain').fadeOut();
setTimeout(() => {
$('.containerThankState').fadeIn();
}, 500)
}
});
function shakeElement(element){
$(element).addClass('shake');
setTimeout(function(){
$(element).removeClass('shake');
},1000);
};
})