File tree 1 file changed +9
-6
lines changed
1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -5,15 +5,18 @@ const panel = document.querySelector('#panel')
5
5
let selectedRating = 'Satisfied'
6
6
7
7
ratingsContainer . addEventListener ( 'click' , ( e ) => {
8
- if ( e . target . parentNode . classList . contains ( 'rating' ) ) {
8
+ if ( e . target . parentNode . classList . contains ( 'rating' ) && e . target . nextElementSibling ) {
9
9
removeActive ( )
10
10
e . target . parentNode . classList . add ( 'active' )
11
11
selectedRating = e . target . nextElementSibling . innerHTML
12
- }
13
- if ( e . target . classList . contains ( 'rating' ) ) {
12
+ } else if (
13
+ e . target . parentNode . classList . contains ( 'rating' ) &&
14
+ e . target . previousSibling &&
15
+ e . target . previousElementSibling . nodeName === 'IMG'
16
+ ) {
14
17
removeActive ( )
15
- e . target . classList . add ( 'active' )
16
- selectedRating = e . target . nextElementSibling . innerHTML
18
+ e . target . parentNode . classList . add ( 'active' )
19
+ selectedRating = e . target . innerHTML
17
20
}
18
21
19
22
} )
@@ -32,4 +35,4 @@ function removeActive() {
32
35
for ( let i = 0 ; i < ratings . length ; i ++ ) {
33
36
ratings [ i ] . classList . remove ( 'active' )
34
37
}
35
- }
38
+ }
You can’t perform that action at this time.
0 commit comments