Created
May 16, 2020 20:43
-
-
Save sienki-jenki/a1e56fd5b4d419234453bd8aa11d73e3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<html> | |
<body> | |
<div id="div"> | |
</div> | |
<script> | |
function foo(e){ | |
console.log(e.target.id); | |
} | |
var div =document.getElementById("div"); | |
for(let i=0; i < 10; i++){ | |
const p = document.createElement("div"); | |
p.id = i; | |
p.innerHTML = i; | |
p.addEventListener("click",foo); | |
div.appendChild(p); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment