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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:38:57+00:00 2026-06-16T21:38:57+00:00

Possible Duplicate: How to distinguish between left and right mouse click with jQuery How

  • 0

Possible Duplicate:
How to distinguish between left and right mouse click with jQuery

How to open context meniu when I click with right mouse click inside the div. Because when I click with right mouse button inside div its fadeouts?

Javascript

$("#link").click(function(e){
   e.stopPropagation();
   div = $("#mydiv").fadeToggle(300);
});

$("#mydiv").click(function(e){
   e.stopPropagation();
});

$(document).click(function(e){
   $('#mydiv').fadeOut(200);
});

HTML

<a id="link">Click</a>
<div id="mydiv" style="width: 200px; height: 200px;">Hello</div>

UPDATE:

Javascript

$("#link").click(function(e){
   e.stopPropagation();
   div = $("#mydiv").fadeToggle(300);
});

$("#good_buttom").click(function(e){
   e.stopPropagation();
   div = $("#hide").fadeToggle(300);
});

$("#mydiv").mousedown(function(e) {
switch (e.which) {
    case 1:
         e.stopPropagation();
         $('#mydiv').fadeOut(200);
        break;
    case 2:
        alert('2');
        break;
    case 3:
        alert('3');
        break;
    default:
        alert('You have a strange mouse');
}
});

HTML

<a id="link">Click</a>
<div id="mydiv" style="width: 200px; height: 200px;">
    <button id="good_button">Click IT</button>
    <div id="hide" style="display:none;">Show up.</div>
</div>
  • 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-06-16T21:38:58+00:00Added an answer on June 16, 2026 at 9:38 pm

    click is only triggered by left mouse click, while mousedown can be triggered by left/middle/right mouse click. So just replace click with mousedown in your code, and distinguish left/middel/right click by checking event.which. Please check How to distinguish between left and right mouse click with jQuery for an example.

    BTW: Checking this link may help you understand the relationship between click, mousedown and mouseup events. And this article: Javascript Madness: Mouse Events maybe also helps. As a rule of thumb, it’s preferable to handle low-level events like mousedown or mouseup instead of high-level events like click or dblclick when you need more control on mouse events.

    One more problem is that you put a superfluous “#” before mydiv in HTML.

    Update: As per your new requirement, you may add the following code to avoid event propagation.

    $("#good_button").mousedown(function(e) {
        e.stopPropagation(); // avoid triggering its parent
        div = $("#hide").fadeToggle(300);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to distinguish between left and right mouse click with jQuery? On
Possible Duplicate: How to distinguish between a variable that is not declared and a
Possible Duplicate: Change href parameter using jQuery I have a page with several links
Possible Duplicate: Difference between iostream and iostream.h My professor said that the following: #include
Possible Duplicate: drawing UIImage inside a CGMutablePath I have a path in my drawRect
Possible Duplicate: RegEx match open tags except XHTML self-contained tags I have a HTML
Possible Duplicate: Should Usings be inside or outside the namespace What is the difference
Possible Duplicate: difference between abstraction and encapsulation? What is the difference between abstraction and
Possible Duplicate: How can a Java program use files inside the .jar for read
Possible Duplicate: Matching an integer between the brackets What is the regex for matching

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.