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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:12:31+00:00 2026-05-29T10:12:31+00:00

Main Problem : Get rid of # when user clicks on anchor tag. I

  • 0

Main Problem : Get rid of # when user clicks on anchor tag. I found a solution for this, which is adding return false; in onClick handler

Secondary Problem : My current code looks like this

<a href="#" onclick="javaScript:toggleDisplay();" title="Some Title">
    @ViewBag.TotalRecords
</a>

And according to solution I got, I want it like this

<a href="#" onclick="javaScript:toggleDisplay();return false;" title="Some Title">
    @ViewBag.TotalRecords
</a>
  • How can I append return false; to my javaScript function call? I can do it manually, but is there any easy way to do this. I am using jQuery?
  • Is there any other way to get rid of #, without modifying the current markup?

EDIT

@ViewBag.TotalRecords: This is a MVC3 ASP.Net thing, but it is not related to the question, hence I didn’t put it in the tags.

Thanks

  • 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-29T10:12:33+00:00Added an answer on May 29, 2026 at 10:12 am

    Thanks Phil, as I said got something out of it. Got not one but two solutions.

    If I add following code to js File, all click handlers are handled (will make it specific for anchor later on)

    Using plain JavaScript (Unobtrusive JavaScript)

    document.addEventListener('click', function (e) {
       e.preventDefault();
       return false;
    });
    

    Using jQuery

    $(document).click(function (e) {
        e.preventDefault();
        return false;
    });
    

    The jQuery Solution is little different than the one suggested by elclanrs, in the sense, if I do $('a').click(function(e){ e.preventDefault(); });, it works for anchor, but I modify my DOM and add new anchor to it, click on this anchor causes # in query string.

    EDIT

    The above solution causes all the clicks to go through the handler, even which I don’t want. Because of this normal anchor with href as url were not working, so this is the working solution

    $("a").live("click", function (e) {
       if ($(this).attr("href") != "#") return;
       e.preventDefault();
       return false;
    });
    

    Hope this helps some one else.

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

Sidebar

Related Questions

About App:--This is a simple app which find the user current location. Problem:-- The
My main activity calls an AsyncTask when a user clicks a button. This AsyncTask
Scroll.js is used for #bird block, which follows the page scrolling. The main problem
For context - read this . Problem: class Program { static void Main() {
I can't figure out the problem in this: #include<stdio.h> int main() { int a,b,count
Main problem: how do i group elements by their Date, only if continuous and
The main problem is as follows: I did my code in console application and
I have a problem in integrating PHP and JQuery: My main file is MyFile.html
I'll only try to present the main part of the problem, because the whole
Short problem: #include <iostream> using namespace std; int main() { double **T; long int

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.