Skip to content

Instantly share code, notes, and snippets.

@lkopacz
Created May 15, 2019 17:04
Show Gist options
  • Save lkopacz/92e9b7376e4d2e498d4f3fcf8b94843f to your computer and use it in GitHub Desktop.
Save lkopacz/92e9b7376e4d2e498d4f3fcf8b94843f to your computer and use it in GitHub Desktop.
JavaScript Event Listeners
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title of the document</title>
</head>
<body>
<button id="button">
Open
</button>
<script src="script.js"></script>
</body>
</html>
const button = document.getElementById('button');
button.addEventListener('click', function() {
this.classList.toggle('expanded')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment