<style>
span {cursor: pointer; color: white;}
.span1 {background: red}
.span2 {background: green}
.span3 {background: blue}
</style>
<div id="div">
<span class="span1">click</span>
<span class="span2">click</span>
<span class="span3">click</span>
</div>
<script>
window.onload = function () {
var div = document.getElementById('div');
div.onclick = function (e) {
e = e || event;
var target = e.target || e.srcElement;
if (target.parentNode == this) {
if (target.className == 'span1') {
alert(1);
} else
if (target.className == 'span2') {
alert(2);
} else
if (target.className == 'span3') {
alert(3);
}
}
}
}
</script>