How to add an overlay DIV to cover an existing DIV (using JQuery)?

@mit $ingh. November 04, 2015 Comments

You can do this by below example :

HTML

<div class="container">
     A lot of content here ...
</div>

 

CSS

.container {
    border: 1px solid;
    height: 200px;
}

 

JAVASCRIPT

$("<div>Loading...</div>").css({
    position: "absolute",
    width: "100%",
    height: "100%",
    top: 0,
    left: 0,
    background: "#ccc"
}).appendTo($(".container").css("position", "relative"));

 

  • jQuery
  • overlay