I have the following line of code in my HTML, which fires off Javascriot functions. I want to separate the JS from the HTML, but I'm not sure how to do it. Here's the code:
<code><li><a id="activatebutton" class="button1" href="javascript:activateIt();" onmousedown="changeimage(); return true;" ></a></li>
</ul></code>
What is happening is that when the user moves his mouse over the link, the image changes. This is handled by the onmousedown event. I return true from this event, because I want the link to activate and call the activateIt() JS function.
Everything works great, except the JS calls are cluttering up my markup..
How do I separate out the javascript calls from the HTML?
I can use addEventListener for the onmousedown, but how do I get rid of the JS function call on the href attribute?
Any assistance would be appreciated.
<code><li><a id="activatebutton" class="button1" href="javascript:activateIt();" onmousedown="changeimage(); return true;" ></a></li>
</ul></code>
What is happening is that when the user moves his mouse over the link, the image changes. This is handled by the onmousedown event. I return true from this event, because I want the link to activate and call the activateIt() JS function.
Everything works great, except the JS calls are cluttering up my markup..
How do I separate out the javascript calls from the HTML?
I can use addEventListener for the onmousedown, but how do I get rid of the JS function call on the href attribute?
Any assistance would be appreciated.