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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:17:09+00:00 2026-05-25T02:17:09+00:00

There are several JQuery plugins to put a modal dialog and show a dom

  • 0

There are several JQuery plugins to put a modal dialog and show a dom element in the dialog. But I’m looking for a dialog overlay which can show some portion of the screen and these region should be accessible, while other elements should be blocked.

  • 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-25T02:17:10+00:00Added an answer on May 25, 2026 at 2:17 am

    I’ve put together a simple plugin to do this… Not sure the extent of your requirements, but it shouldn’t be too hard to build on it.

    Basic usage is as follows (note that if your selector matches multiple elements, it will just mask the first):

    $("#yourDiv").mask();
    

    Masking another element will unmask other masked elements or you can explicitly unmask things with:

    $("#yourDiv").unmask();
    

    Plugin code:

    (function( $ ){
        $.fn.mask = function() {
            this.unmask();
    
            var totalWidth = $(document).width();
            var totalHeight = $(document).height();
    
            var target = this.first();
            var maskWidth = target.outerWidth();
            var maskHeight = target.outerHeight();
            var maskOffset = target.offset();
    
            addMask(0, 0, maskOffset.left, totalHeight);                                                                    //left
            addMask(maskOffset.left + maskWidth, 0, totalWidth - (maskOffset.left + maskWidth), totalHeight);                 //right
            addMask(maskOffset.left, 0, maskWidth, maskOffset.top);                                                         //top
            addMask(maskOffset.left, maskOffset.top + maskHeight, maskWidth, totalHeight - (maskOffset.top + maskHeight));    //bottom
    
            var btn = $("<input type='button' value='Cancel' class='mask' />");
            $("body").append(btn);
            btn.css({ position: "absolute", zIndex: 9999, top: (maskOffset.top + maskHeight + 5), left: (maskOffset.left + maskWidth - btn.outerWidth(true)) });
            btn.click(function() { $(this).unmask(); });
    
            return this;
        };
        $.fn.unmask = function() {
            $(".mask").fadeOut(function() { $(this).remove(); });
        };
    
        function addMask(x, y, w, h) {
            var mask = $("<div class='mask'></div>");
            mask.css({ position: "absolute", zIndex: 9999, width: w, height: h, top: y, left: x, display: "none" });
            //comment out this line & replace with css styles on 'div.mask' if you want to customise
            mask.css({ backgroundColor: "#000", opacity: 0.3, filter: "alpha(opacity=30)" });
            $("body").append(mask);
            mask.fadeIn();
            // mask.click(function() { $(this).unmask(); });
        }
    })( jQuery );
    

    Edit: Bug fix with the panel dimensions, added a fade in/out & now removes the mask if you click outside you’re masked region has a cancel button to remove the mask.

    Edit 2: JsFiddle demo

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

Sidebar

Related Questions

there are several list filters in jquery (quicksand, filterprojects, etc.), but I am looking
There are several advanced jQuery plugins which filter <div> s by corresponding id or
I've tried out several solutions and jQuery plugins to solve this issue but for
There are several threads on this here at SO but I didn't find one
There are several other questions about this topic that I have gone through, but
There are several variant questions on this on SO, but I did not find
There are several different ways I can initialize complex objects (with injected dependencies and
I've written a small lightbox plugin for jQuery (yes, there are several ready made
Is there a way to implement pagination like Googles show more results with jQuery
My dev environment is LAMP-based (Drupal); there are several JS (jQuery) files that are

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.