Display Loading Image While Page Loads using jQuery and CSS

How to Display Loading Image While Page Loads using jQuery and CSS

HTML-

Add the following HTML after the <body> opening tag.
<div class="loader"></div>

CSS - 

Use the following CSS to display a loading image on loader div.
.loader {
    position: fixed;
    left: 0px;
    top: 0px;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background: url(image URL) 50% 50% no-repeat rgb(249,249,249);
    opacity: .8;
}

CODE - 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>

<script type="text/javascript">
$(window).load(function() {
    $(".loader").fadeOut("slow");
});
</script>

Note:- You can do customization in the CSS and image type as per your requirement. Happy Coding :)

Comments

Popular posts from this blog

How to Customize exported excel's cell background color in Datatables

Populate dropdown using jquery ajax in SharePoint

Clear DataTable on button click