File tree 1 file changed +16
-16
lines changed
1 file changed +16
-16
lines changed Original file line number Diff line number Diff line change 11
11
display : inline-block;
12
12
margin : 20px ;
13
13
}
14
- # category1 {
14
+ # category0 {
15
15
background-color : aqua;
16
16
}
17
- # category2 {
17
+ # category1 {
18
18
background-color : blue;
19
19
}
20
- # category3 {
20
+ # category2 {
21
21
background-color : gray;
22
22
}
23
23
</ style >
24
24
</ head >
25
25
< body >
26
+ < div id ="category0 "> </ div >
26
27
< div id ="category1 "> </ div >
27
28
< div id ="category2 "> </ div >
28
- < div id ="category3 "> </ div >
29
29
< script >
30
30
'use strict' ;
31
- // for (var i = 0; i < 4; i += 1) {
32
- // (function(j) {
33
- // $('#category' + j).click(function navClickHandler() {
34
- // console.log(j);
35
- // });
36
- // }(i));
37
- // }
38
- // the let key word will stay with the scope for each click handler
39
- for ( let i = 0 ; i < 4 ; i += 1 ) {
40
- $ ( '#category' + i ) . click ( function navClickHandler ( ) {
41
- console . log ( i ) ;
42
- } ) ;
31
+ for ( var i = 0 ; i < 4 ; i += 1 ) {
32
+ ( function ( j ) {
33
+ $ ( '#category' + j ) . click ( function navClickHandler ( ) {
34
+ console . log ( j ) ;
35
+ } ) ;
36
+ } ( i ) ) ;
43
37
}
38
+ // the let key word will stay with the scope for each click handler
39
+ // for (var i = 0; i < 3; i += 1) {
40
+ // $('#category' + i).click(function navClickHandler() {
41
+ // console.log(i);
42
+ // });
43
+ // }
44
44
</ script >
45
45
</ body >
46
46
</ html >
You can’t perform that action at this time.
0 commit comments