Skip to content

Instantly share code, notes, and snippets.

@rrameshbtech
Created July 30, 2018 03:16
Show Gist options
  • Save rrameshbtech/4ef8ecd4fe2689d8646646736b991351 to your computer and use it in GitHub Desktop.
Save rrameshbtech/4ef8ecd4fe2689d8646646736b991351 to your computer and use it in GitHub Desktop.
<html>
<button id="thisButton">Check this</button>
<script>
const thisButton = document.getElementById('thisButton');
thisButton.addEventListener('click', verifyThis);
function verifyThis(event) {
//this is bound to the button onwhich the click event is triggered
console.log(this === thisButton); // true
console.log(this === event.currentTarget); // true
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment