Skip to content

Instantly share code, notes, and snippets.

@ivandevp
Created May 31, 2017 14:40
Show Gist options
  • Save ivandevp/39f2c4f02d2fbb0bec579abca63ee083 to your computer and use it in GitHub Desktop.
Save ivandevp/39f2c4f02d2fbb0bec579abca63ee083 to your computer and use it in GitHub Desktop.
this vs. e.target
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>This vs. Target</title>
</head>
<body>
<div id="elemento">
<button type="button">Click me!</button>
<p>Hola!</p>
</div>
<script>
window.onload = function () {
var elemento = document.getElementById("elemento");
elemento.onclick = function (e) {
console.log("target", e.target);
console.log("this", this);
};
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment