File tree Expand file tree Collapse file tree 2 files changed +92
-0
lines changed Expand file tree Collapse file tree 2 files changed +92
-0
lines changed Original file line number Diff line number Diff line change 1+ <!doctype html>
2+ < html >
3+ < head >
4+ < title > Let, scope, and closures</ title >
5+ < meta charset ="utf-8 ">
6+ < style >
7+ div {
8+ padding : 5px ;
9+ margin : 5px ;
10+ border : 1px solid black;
11+ background-color : lightgray;
12+ width : 100px ;
13+ cursor : pointer;
14+ }
15+ </ style >
16+ < script src ="https://traceur-compiler.googlecode.com/git/bin/traceur.js "
17+ type ="text/javascript "> </ script >
18+ < script src ="https://traceur-compiler.googlecode.com/git/src/bootstrap.js "
19+ type ="text/javascript "> </ script >
20+ < script >
21+ traceur . options . experimental = true ;
22+ </ script >
23+ < script type ="module ">
24+ window . onload = function ( ) {
25+ var button = document . getElementById ( "button" ) ;
26+ button . onclick = function ( ) {
27+ var body = document . querySelector ( "body" ) ;
28+ for ( let i = 0 ; i < 3 ; i ++ ) {
29+ var div = document . createElement ( "div" ) ;
30+ div . id = "div" + i ;
31+ div . innerHTML = "This is div " + i ;
32+ div . onclick = function ( ) {
33+ console . log ( "You just clicked div " + i ) ;
34+ } ;
35+ body . appendChild ( div ) ;
36+ }
37+ } ;
38+ } ;
39+ </ script >
40+ </ head >
41+ < body >
42+ < h1 > let, scope, and closures</ h1 >
43+ < button id ="button "> click me</ button >
44+ </ body >
45+ </ html >
46+
Original file line number Diff line number Diff line change 1+ <!doctype html>
2+ < html >
3+ < head >
4+ < title > Let, scope, and closures</ title >
5+ < meta charset ="utf-8 ">
6+ < style >
7+ div {
8+ padding : 5px ;
9+ margin : 5px ;
10+ border : 1px solid black;
11+ background-color : lightgray;
12+ width : 100px ;
13+ cursor : pointer;
14+ }
15+ </ style >
16+ < script src ="https://traceur-compiler.googlecode.com/git/bin/traceur.js "
17+ type ="text/javascript "> </ script >
18+ < script src ="https://traceur-compiler.googlecode.com/git/src/bootstrap.js "
19+ type ="text/javascript "> </ script >
20+ < script >
21+ traceur . options . experimental = true ;
22+ </ script >
23+ < script type ="module ">
24+ window . onload = function ( ) {
25+ var button = document . getElementById ( "button" ) ;
26+ button . onclick = function ( ) {
27+ var body = document . querySelector ( "body" ) ;
28+ for ( var i = 0 ; i < 3 ; i ++ ) {
29+ var div = document . createElement ( "div" ) ;
30+ div . id = "div" + i ;
31+ div . innerHTML = "This is div " + i ;
32+ div . onclick = function ( ) {
33+ console . log ( "You just clicked div " + i ) ;
34+ } ;
35+ body . appendChild ( div ) ;
36+ }
37+ } ;
38+ } ;
39+ </ script >
40+ </ head >
41+ < body >
42+ < h1 > let, scope, and closures</ h1 >
43+ < button id ="button "> click me</ button >
44+ </ body >
45+ </ html >
46+
You can’t perform that action at this time.
0 commit comments