Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 299211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:48:08+00:00 2026-05-12T06:48:08+00:00

I have an anchor that doesn’t go anywhere but has an onclick (e.g. <a

  • 0

I have an anchor that doesn’t go anywhere but has an onclick (e.g. <a onclick="..."></a>). My question pertains to the href attribute. What should I put for the value?

If I simply omit href, the anchor doesn’t have the appropriate decoration–the mouse pointer icon doesn’t change when the mouse is put over it.

If I use href="#", then the window scrolls to the top of the page when the link is clicked.

If I use href="javascript:..." and put the value of onclick proceeding javascript:, the page is left and the address bar contains the Javascript when the link is clicked.

When I refer to browser behavior, I’m referring to Chrome, which I’m testing it in to start with.

What should I be putting for href when the anchor isn’t an actual link but exists only to have the onclick perform behavior?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:48:08+00:00Added an answer on May 12, 2026 at 6:48 am

    In your onclick handler, add this to the end:

    return false;
    

    This will cancel the default processing (i.e. following the link) and you can put whatever you want in the href (the # is as good as any).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an anchor element that looks like this <a href=url><img src=imgurl/>Text</a> I would
I have a bunch of anchor tags that I want to select. But if
I want to identify anchor tags that have an href containing a particular string
I have an onclick function that I want to add an anchor to the
My page contain lots of anchor and i have to put that html in
Using jquery I have a clicking tab mechanism that are nothing but anchor tags
I have a MVC app and using JQuery. I have anchor that I setup
I have a variety of anchor tags and input buttons that trigger a variety
I have a table row that needs to be hidden when the anchor with
I have a tooltip on an anchor element, that sends an AJAX request on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.