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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:16:09+00:00 2026-05-19T16:16:09+00:00

I am using event.preventDefault() to prevent concatenation of # which is the href of

  • 0

I am using event.preventDefault() to prevent concatenation of # which is the href of an anchor to the URL. I am performing events on the mousedown() and mouseup() parts of the click which is why I can’t use click. But event.preventDefault() is not preventing the concatenation of # to the URL when envoking mouseup() or mousedown() methods. How can I get around this?

  • 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-19T16:16:10+00:00Added an answer on May 19, 2026 at 4:16 pm

    If you’re talking about clicking a link, it is probably because there isn’t a default behavior to prevent for mousedown and mouseup.

    The default behavior of clicking a link requires a combination of mousedown plus mouseup on the link. If you mousedown then drag off the link before you mouseup, the link is not followed. The same vice-versa.

    Only when you mousedown then mouseup is the default behavior activated. That event is represented by the click event.


    EDIT: I guess I forgot to answer the question.

    How do you get around it? Add a click() event handler that does e.preventDefault().

    $('a.myElement').click(function(e){e.preventDefault()});
    

    If you also want to stop propagation of the event, and if you’re using jQuery 1.4.3 or later, you can do this:

    $('a.myElement').bind('click',false);
    

    From the docs for the bind()(docs) method:

    Setting the third argument to false will attach a function that prevents the default action from occurring and stops the event from bubbling.

    Again, it requires jQuery 1.4.3 or later.

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

Sidebar

Related Questions

Here is the function that i am using: $('.urlz').click(function (event) { event.preventDefault(); var url
I Using this code <script type=text/javascript> $(function() { $('#DoTask').click(function(event) { event.preventDefault(); // added this
I am using Ajax to receive a JSON update: $(document).ready(function(){ $('form').submit(function(event){ event.preventDefault(); var form
I'm trying to prevent the default anchor link and onclick event to trigger. Here's
Below is problem and code: I'm clicking on an anchor which has an href
I'm having trouble using the event.preventDefault(); for an ahref on my DOM. How do
I'm using the following code to prevent event propagation: function mapSlider(e) { if ($('.slideme').hasClass('open'))
<button type=button value=click me onclick=check_me(); /> function check_me() { //event.preventDefault(); var hello = document.myForm.username.value;
My HTML which is at this url '/main/' contains the following link: <a href=/main/
$('a').click(function(event){ $('body').html('loading...'); $.post('www.sitename.com/hello',{site:http//:www.google.com},function(data) { alert(data); }); event.preventDefault(); }); I am using the above script

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.