Skip to content

Commit

Permalink
Replaced onchange to EventListener to detect change (#772)
Browse files Browse the repository at this point in the history
The MDN example that redirects to this code uses EventListener method to
detect change in select element. I learned that standard practice is
using EventListener method, hence the change.

Co-authored-by: Brian Thomas Smith <[email protected]>
  • Loading branch information
bhagyeshsp and bsmth authored Oct 28, 2024
1 parent 549fb2a commit 37f6787
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion javascript/building-blocks/simple-switch.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
const select = document.querySelector('select');
const para = document.querySelector('p');

select.onchange = setWeather;
select.addEventListener("change", setWeather);

function setWeather() {
const choice = select.value;
Expand Down

0 comments on commit 37f6787

Please sign in to comment.