Asked 8 years ago
16 Sep 2016
Views 941
jqueryLearner

jqueryLearner posted

how to disable redirection on click of the link ?



<a href='/' onclick='showModal("register.php")' >
 Login
</a>


when i click on the link for code above . it s goes to index page of site but i want to show Modal popup on the click of the link. so it should run showModal function instead of redirecting to home page of website .

Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00

you can disable redirection of the link and jst run the click js event by many ways

1. use void() instead of '/'

<a href='void();' onclick='showModal("login.php")' >
 Login
</a>

2.use return false

<a href='function(){return false;}' onclick='showModal("register.php")' >
 Login
</a>

3. remove href and jst put onclick event

<a   onclick='showModal("register.php")' >
 Login
</a>


probably more ways comeup if you try to research

Thanks !!
Post Answer