I have seen and avoided code like this:
<div id="myDiv" onClick="alert('hi!');">Div</div>
<script>
myDiv.click(); // <-- this bit seems wrong
</script>
It just seems wrong to me that I should refer to the node by it's id alone without explicitly assigning it to a variable first. Like this:
var myDiv = document.getElementById('myDiv');
Is there a good reason why we shouldn't use code like in the first example or am I just superstitious?