Created
May 31, 2017 14:40
-
-
Save ivandevp/39f2c4f02d2fbb0bec579abca63ee083 to your computer and use it in GitHub Desktop.
this vs. e.target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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