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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:23:14+00:00 2026-05-27T13:23:14+00:00

I am trying to achieve a modal overlay using jQuery. When a user clicks

  • 0

I am trying to achieve a modal overlay using jQuery.

When a user clicks on a particular button the popup div has to open up. The rest of the page should be grayed out. In other words nothing on the page can be selected or clicked other than this pop up.

How can this be acheived?

I have written the follwing: CODE and result is HERE

I am not able to focus only on the div. For me the background is also active. How do I disable the area other than the pop up div?

HTML:

<div id="mainContainer">
  I am in the main body section.               
</div>
<input type="button" value="Show Overlay" id="btn">        
<div id="overlayContainer">
    I am in the Overlay Section<span style="float:right"><a class="alink" href="javascript:void(0);">X</a></span>
</div>

JS:

$(function() {
    $("#btn").click(function() {
        $("#overlayContainer").fadeIn();
        $("#mainContainer");
    })
    $(".alink").click(function() {
        $(this).parent().parent().hide();
    });
})

Css:

#mainContainer{border:2px solid red;width:700px;height:500px;margin:0 auto;}
#overlayContainer{background:#c0c0c0;width:300px;height:400px;right:500px;border:2px dotted blue;margin-top:-460px;display:none;position:fixed;}
input{text-align:center;margin-left:300px;margin-top:18px;position:fixed;}
  • 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-27T13:23:15+00:00Added an answer on May 27, 2026 at 1:23 pm

    You asked for no plugins, but then tagged your question jquery-ui, which is itself a plugin. First, here’s your jQuery-UI answer:

    $("#overlayContainer").dialog({ modal: true });
    

    http://jsfiddle.net/AMM2M/5/

    And here’s your no plugin answer:

    Cover the entire page with an overlay div, then place a popup div over that. To display the popup, show and hide a common container.

    http://jsfiddle.net/AMM2M/6/

    <div class="popup">
        <div class="overlay"></div>
        <div class="content">
            popup content here
        </div>
    </div>
    
    .popup {
        display: none;
    }
    .popup .overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: #fff;
        opacity: 0.5;
        filter: alpha(opacity=50);
        z-index: 90;
    }
    .popup .content {
        position: absolute;
        top: 50%;
        left: 50%;
        height: 400px;
        width: 300px;
        margin-left: -150px;
        margin-top: -200px;
        background: #fff;
        z-index: 91;
    }
    
    $(".popup").show();
    

    Answered from my Windows 7 Phone

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

Sidebar

Related Questions

What I am trying to achieve is a form that has a button on
I'm trying to make a modal dialog in the least amount of jQuery code
I have a requirement to show a custom modal jQuery confirmation when a user
I'm using the jQuery UI modal dialog, and populating it with some form fields.
I'm trying to achieve optimization based on deterministic behavior of a user defined function
I am trying to achieve a category model where name has unique=True , but
I am trying to achieve better performance for my Java SWT application, and I
What I'm trying to achieve is to determine if the Postscript that I'm parsing
I'm trying to achieve the equivalent of a WinForms ListView with its View property
I'm trying to achieve a 50px space at the bottom of my page, below

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.