Reputation: 321
the a tag is used in Jquery dropdown menus and generally in ajax . But the problem it refeshes the page . How can I force it not to refresh ?
Thanks,
Upvotes: 2
Views: 7829
Reputation: 61
Just add javascript:void(0)
in href
Example: <a href="javascript:void(0)">Home</a>
Upvotes: 6
Reputation: 10680
I had a similar issue, and did this to resolve.
href
attribute. Many people will set it to "#" because "it doesn't go anywhere". Not entirely true. It'll take you to the top of the page, which is a pain when you have a scrolling page.cursor : pointer
If you do those two things, your a tags won't go anywhere, won't scroll the screen and will look like regular links when a user mouses over them.
Upvotes: 0
Reputation: 72755
You can add a handler for the click
event on your anchors which after doing its work (executing and processing an Ajax request) returns False. This will prevent the event from propagating and calling the default handler (which is to GET
the resource referred to by href
).
Upvotes: 1