144
rated 0 times
[
146]
[
2]
/ answers: 1 / hits: 16706
/ 10 Years ago, wed, february 11, 2015, 12:00:00
<html>
<head>
<script type=text/javascript>
function getElement(e) {
var element = e.target || e.srcElement;
alert(element.id);
}
</script>
</head>
<body onclick=getElement()>
<div id=div1></div>
<div id=div2></div>
</body>
</html>
Tried this to get the ID of element clicked and alert it.
I'm sure it's something pretty basic I'm missing.
Can anyone help?
More From » javascript