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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:22:17+00:00 2026-05-13T16:22:17+00:00

I am trying to create an overlay for a div. I am attempting to

  • 0

I am trying to create an overlay for a div. I am attempting to accomplish this using JQuery. This what the JS looks like:

 $('#container').wrapInner('<div />')
        .css('opacity', '0.5')
        .css('z-index', '2')
        .css('background','black')
        .attr('id','overlay')
    }
};

Update: This is the markup before the JS function is applied:

<body>
<form id="form1" runat="server">
<div id="header">My Header</div>
<div id="container">Container</div>
<div id="menu">
 <input type="text" />
 <input type="button" class="button" value="Go" onclick="overlay.toggleOverlay();return true" />        
</div>  
</form>

This seems to manipulate the ‘container’ div in a way I would not have expected. This is what the markup looks like after the wrapInner method is run:

<div id="overlay" style="z-index: 2; filter: alpha(opacity=50); ZOOM: 1; background: black;">
<div>ContainerDiv</div>
</div>

It is as if the wrapInner method has striped the container div of its attributes. Can someone suggest to me a better way of doing this?

Thanks..

  • 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-13T16:22:18+00:00Added an answer on May 13, 2026 at 4:22 pm

    The Wrap() method is what I needed

     $('#container').wrap("<div id='overlay'> </div>")
            .css('opacity', '0.5')
            .css('z-index', '2')
            .css('background','black')
    

    Update:

    In the end it decided to not wrap the container div with the overlay. The styling was getting tricky so I just decided to make the overlay div a sibling of container and then position it over the container. I am using offset values of the container to do this.

    var left = $("#container").offset().left;
            var top = $("#container").offset().top;
            var width = $("#container").outerWidth();
            var height = $("#container").outerHeight();
            $("#overlay").css({ "left": left + "px", "top": top + "px", "width": width + "px", "height": height + "px", "opacity": "0.5" });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create an overlay, similar to the one that jQuery UI
Trying to create several layers of folders at once C:\pie\applepie\recipies\ without using several different
I'm trying to create a sitemap using Linq to Xml, but am getting an
I'm trying to create a function which will add an overlay to a thumbnail
I'm trying to create a calendar in an HTML table design with CSS element
So, I'm trying to create a div class that will display in a row
I've been playing around trying to create a transparent window that will overlay another
I am trying create a WCF service that leverages the WPF MediaPlayer on the
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
Trying to create a user account in a test. But getting a Object reference

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.