Why will the following code show "three" then "two"and then "one" (in this order)? Is it something to do with the function or the table? I was expecting the output to be one, two, three and not the other way around.
<html>
<head>
<title>WebDev Exams</title>
</head>
<body>
<div id='one'>
<table>
<tr id='two'>
<td id='three'>Ce1111</td>
</tr>
</table>
</div>
</body>
<script type="text/javascript">
function registerEvent(id) {
document.getElementById(id).addEventListener('click', function()
{
alert(id);
});
}
registerEvent('one');
registerEvent('two');
registerEvent('three');
</script>
</html>