Skip to content

Commit 13a301e

Browse files
committed
Event listeners with code
1 parent c079531 commit 13a301e

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"liveServer.settings.port": 5501
3+
}

Lectures Codes/11 Callback Fucntion in javaScript .js

+14-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ x(function y() {
1111
});
1212

1313
//Event handler and listeners in javascript
14-
document.getElementById("clickMe").addEventListener("click", function xyz() {
15-
console.log("button clicked");
16-
})
14+
document.getElementById("clickMe")
15+
.addEventListener("click", function xyz() {
16+
console.log("button clicked");
17+
})
18+
19+
//Event handler and listeners in javascript using closures finding the count of click.
20+
function attachEventListener() {
21+
let count = 0;
22+
document.getElementById("clickMe")
23+
.addEventListener("click", function xyz() {
24+
console.log("Button clicked", ++count);
25+
})
26+
}
27+
attachEventListener();

0 commit comments

Comments
 (0)