I have this code:
<script type="text/javascript">
window.onload = function () {
document.getElementById('image011').onclick = hideTopMenu();
}
</script>
In my case, I cant use JQuery, I need to use pure javascript only.
Can someone tell me where the problem is?
After page load, if I click on image011, the top menu will be hidden. Regards
You need to assign a function reference as event handler.
What you are doing is, assign the result from the function call
hideTopMenu()So, your line needs to look like: