Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger onClick before href

I am trying to do some functionality in onClick() event and also doing the href for the same element. But actually happening is its not triggering onClick() completely and its moving to href link when we click that element.

How to make onClick() gets complete first and trigger href next.

<a href="" onclick="javascript:triggerMe()">click</a>
like image 250
Vinoth Babu Avatar asked Dec 04 '13 13:12

Vinoth Babu


1 Answers

As I understood, you don't want to go on other page, so use return false, like this:

<a href="" onclick="javascript:triggerMe();return false;">click</a>
like image 190
equinox Avatar answered Oct 07 '22 03:10

equinox