I want to pass 2 javascript events in one click, I put 2 of them into href and onclick. But when I click, it always executes the onclick action. Click again or a third time, the href action gets executed. I do not know how it was like this.
How do I to solve it?
If I combine 2 javascript events in one part(href or onclick). is it could run well? how to?
thanks.
<a href="javascript:function1('value1')" onclick="javascript:function2('value2')">
Try this:
Note that you do not need to put “javascript:” in the onclick event. And it is generally better to use onclick rather than href to execute javascript.
You could even change
href="#"to link to a page saying you need javascript enabled.return false;will cancel the link if javascript is working.