Created
February 18, 2018 01:18
-
-
Save malikkurosaki/4afcd9bc70a25607e774cbe7ea81135a to your computer and use it in GitHub Desktop.
get id of element when on click
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
<div di="container"> | |
<div id="a">this is a</d> | |
<div id="b">this is b</d> | |
<div id="c">this is c</d> | |
<div id="d">this is d</d> | |
<div id="e">this is e</d> | |
<div id="f">this is f</d> | |
<div id="g">this is g</d> | |
<div id="h">this is h</d> | |
<div id="i">this is i</d> | |
<div id="j">this is j</d> | |
</div> | |
<div id="result">result here</div> | |
<script> | |
document.body.onclick = function(ev){ | |
document.getElementById("result").innerHTML = ev.target.id; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment