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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:42:42+00:00 2026-06-15T10:42:42+00:00

This is the problem I am having. I need to attach some kind of

  • 0

This is the problem I am having. I need to attach some kind of handle to a draggable div.

What I need to do is capture the right mouse button every time that I right click on div within the parent.

This is my child creation code. This code works fine and I can create multiple div without a problem.

var smallBlock = $('<div class="SmallBlock"></div>').appendTo("#canvas");
smallBlock..draggable({containment: "#canvas", scroll: false, grid: [10, 10]}, {cursor: "move", cursorAt: {top: 125, left: 150}})
smallBlock.append('<div class="article_title fontCenter fontBold font32">Article Title</div>')
smallBlock.append('<div class="article_Image"><img style="width: 250px;" src="<? echo $image1 ?>"></div>')
smallBlock.append('<div class="font14"><? echo substr($article_text, 0, 200) ?></div>') 

And this is the mouse click code.

<script type="text/javascript">

function getRightClick()
{
    // check for right mouse pressed

$('#canvas').mousedown(function(event) {
    switch (event.which) {
        case 1:
            alert('Left mouse button pressed');
            break;
        case 2:
            alert('Middle mouse button pressed');
            break;
        case 3:
            alert('Right mouse button pressed');
           break;
        default:
            alert('You have a strange mouse');
    }
});
}

</script>

I have no idea how to make the get the div to recognize that a right mouse was clicked over it.

BTW, there are other classes of divs within the parent which I need to detect; so a more general solution might be better.

  • 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-15T10:42:43+00:00Added an answer on June 15, 2026 at 10:42 am

    you could add this to the context id element:

    oncontextmenu="alert('right click on element');return false;
    

    or perhaps this:

    jQuery('#yourDIVId').mousedown(function(event) {
       var rightclk = false;
       if (event.which) rightclick = (event.which == 3);
         if(rightclk == true){
            alert('yes')
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an CSS problem, i need to achieve this article div#comments-wrapper ul.sub-comment:before {
I'm having this problem right now: given a month and a year, I'd need
I've having this problem with some JavaScript code. I've simplified it in the error
We are having this problem with a controller right now; the controller looks like
I'm having this problem : I have some divs wich are animated with jquery,
I have been having this problem for quite some time. I create a dataset
I am having problem with the following code, I need to do some modification
I'm having this problem I need to build an adhoc build for each of
I'm having problems with this site I am building. I need a fixed width
I have this problem having to display my jasper report on my grails application.

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.