File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge " />
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
7+ < title > Adding Event Listeners</ title >
8+ </ head >
9+ < body >
10+ < div id ="output "> </ div >
11+ < script >
12+ const output = document . getElementById ( "output" ) ;
13+
14+ output . innerHTML = `
15+ <h1 id="title">Adding Event Listeners</h1>
16+
17+ <button type="button" id="btn" class="btn remove buy">Click me</button>
18+
19+ ` ;
20+ const btn = document . querySelector ( "button" ) ;
21+
22+ function handleClick ( event ) {
23+ console . log ( "btn is clicked" ) ;
24+ document . getElementById ( "title" ) . innerText = "Kill Me Heal Me" ;
25+
26+ console . log ( event ) ;
27+ console . log ( event . type ) ;
28+ console . log ( event . target ) ;
29+ console . log ( this ) ;
30+ }
31+ btn . addEventListener ( "click" , handleClick ) ;
32+ </ script >
33+ </ body >
34+ </ html >
Original file line number Diff line number Diff line change 1212 const output = document . getElementById ( "output" ) ;
1313
1414 output . innerHTML = `
15- <h1>Set and Get Inline Styles </h1>
15+ <h1>Set and Get Classes </h1>
1616 <button type="button" class="btn btn-active">Click me</button>
1717 <button type="button" id="btn" class="btn remove buy">Click me</button>
1818
You can’t perform that action at this time.
0 commit comments