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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:48:47+00:00 2026-06-07T16:48:47+00:00

I am trying to implement a contextmenu that appears on right click to div

  • 0

I am trying to implement a contextmenu that appears on right click to div with class contextFolder which has z-index: 1000.

To do that, I bind contextmenu event to divs with JQuery. This is working fine. I want this contextmenu to disappear when

  • User left clicks anywhere on the screen,
  • User right clicks anywhere on the screen except any other div.contextfFolder

If while contextmenu is opened and right click happens on other div.contextFolder, I want my current contextmenu to disappear and open a new one on new div.contextFolder.

To do that when I show to contextmenu,

  • I also create a overlay with height: 100%, width: 100%, and z-index: 100.
  • I bind left click event to this overlay such that when it is clicked,
    • overlay is removed,
    • contextmenu is hidden.
  • I also bind contextmenu to overlay to hide contextmenu and remove overlay when right clicked to any point except another div.contextFolder
  • To prevent left click event of overlay on contextmenu, I also assign z-index: 101 to contextmenu. (z-index of overlay is 100)

This seems all fine to me.(I am newbie in CSS, so I might be missing something very obvious).

All working fine, except when I right click on div.contextFolder when a contextmenu is already open on another div.contextFolder, it goes to contextmenu event of overlay (which hides to current one). I want new one to open.

I have tested this in Chrome and Firefox latest versions.

This is the fiddle.

Thank you.

  • 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-07T16:48:49+00:00Added an answer on June 7, 2026 at 4:48 pm

    I’ve just created a fiddle for you.
    All I did was rework your javascript.

    JSFiddle

    Hope that helps you.

    PS: I also added other code which checks to see whether clicks after the initial opening of a menu are clicks on a child of the menu

    Cheers

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

Sidebar

Related Questions

SetFocus I'm trying implement the above Se Focus code in a Class Library that
Trying to implement a function in my linkedlist class that will return total amount
I'm trying implement A* Start path finding in my games(which are written with JavaScript,
I'm trying to implement Copy as path option in windows context menu ,which copies
Trying to implement a function that will return a list of ints the represent
I'm trying to create a TreeView which has two levels but I'm getting nowhere.
Trying to implement a shell, mainly piping. I've written this test case which I
Trying to implement a MSMQ-backed WCF PubSub. I understand that net.msmq is one-way; however
trying to implement a dialog-box style behaviour using a separate div section with all
I'm trying implement pull to refresh on a ListFragment but right now none of

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.