Amadeu Cabanilles Amadeu Cabanilles - 1 month ago 9
Javascript Question

JSP: Display Loading Image While Page Loads

I have these code in my JSP to Display a Loading Image While Page Loads:

<style type="text/css">
.loader {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
background: url('${contextPath}/images/page-loader.gif') 50% 50% no-repeat rgb(249,249,249);
}
</style>

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

<div class="loader"></div>


and it is working fine. Now I want to show the same image after clicking a link with these code

<script type="text/javascript">
$(document).ready(function () {
$('a').click( function(e) {
$(".loader").fadeOut("slow");
} )
});
</script>


But Its not working at all

Answer
<script type="text/javascript">    
$(document).ready(function () {
    $('a').click( function(e) {
        $(".loader").fadeIn("slow");
        } )
    });
</script>
Comments