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 7496749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:46:00+00:00 2026-05-29T18:46:00+00:00

I usually have to bind a JavaScript function to an anchor-click event. That is

  • 0

I usually have to bind a JavaScript function to an anchor-click event. That is easy using jquery or the onclick inline attribute.

But, my problem is that I never know what the best way to keep href empty is.

For instance:

  1. <a href="javascript:void(0)"> – It seems like a bit too much code for just being empty
  2. <a href=#> – If I don’t want to move to another page, I must return
    false in the JavaScript call
  3. <a href> – This option breaks the
    cursor and hover style and the browser doesn’t render it as a link
  4. <a> – idem

What is the best href value for empty anchors? I’m not interested to keep functionality without JavaScript

  • 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-29T18:46:00+00:00Added an answer on May 29, 2026 at 6:46 pm

    The right one is to use an empty a element href attribute and bind the click event in Javascript.

    For unobtrusive design, you should have a href attribute with a proper link (so those without Javascript can still use the site) and remove the attribute in Javascript, binding the click event.

    If you are simply using the a element as a target to bind the click event to, consider using a div or span instead.

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

Sidebar

Related Questions

I usually have jQuery code that is page specific along with a handful of
It's a known fact that Windows applications usually have 2Gb of private address space
When I run an MSI (without parameters) I usually have to click my way
I have two entities that usually have one-to-many relationship, but in rare cases should
I have any number of anchor links on a page that need to execute
I usually have an environment setting for MAKE_MODE (Windows XP, using GNU make, both
Module in macruby has many methods that it doesn't usually have. One of these
Usually when I subscribe to an event, I use the Visual Studio builtin function
I usually have my structure laid out something like this: <div id=all> <div id=page>
When performing many inserts into a database I would usually have code like this:

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.