xRobot
xRobot

Reputation: 26565

How to avoid to display '#'?

when I click:

<a href="#" onclick="plus();">+ 1 </a>

then in the address bar appears '#' in addition to URL ( example.com/index.php?id=1# ).

Is there a way to avoid that ?

Upvotes: 2

Views: 81

Answers (3)

David Pooley
David Pooley

Reputation: 81

use preventDefault(); instead of return false.

for the reasons explained here. http://fuelyourcoding.com/jquery-events-stop-misusing-return-false/

Upvotes: 1

Paddy
Paddy

Reputation: 33867

Or this:

<a href="javascript:plus();">+ 1 </a>

Upvotes: 4

VisioN
VisioN

Reputation: 145428

You can add return false. It will prevent the default action.

<a href="#" onclick="plus(); return false;">+ 1</a>

Upvotes: 6

Related Questions