Menu
I have tried to assing an onclick event to an HTML object, but for some reason the event is ignored. Can anyone advise what’s wrong with the code?
This doesn’t work:
[CODE]<span id=myArea>Click Me</span>
<script language=”javascript”>
document.getElementById(“myArea”).onclick = “alert(‘My Message’)”
</script>
This is what it should be equivalent to (and which works):
[CODE]<span id=myArea onclick = “alert(‘My Message’)”>Click Me</span>