Skip to content

Commit caa16b9

Browse files
committed
addEventListener
1 parent 6859160 commit caa16b9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

17.addEventListener.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// select element
2+
// addEventListener
3+
// what event,
4+
// and what to do (callback function/annonymous funciton/function reference)
5+
6+
const btn = document.querySelector('.btn');
7+
const h3 = document.querySelector('h3');
8+
9+
btn.addEventListener('click', function () {
10+
// if click btn h3 will add class blue
11+
h3.classList.add('blue');
12+
});

0 commit comments

Comments
 (0)