Clinton Green
Clinton Green

Reputation: 9977

How to add loading text that dissapears once page is loaded

I have a page that loads videos via .load(). I want to add loading text that disappears once the page is loaded. Please can someone tell me how to accomplish this, I have no idea how to tell if the page is finished loading, so I don't know when to remove the loader.

JS

 // define var video
var video = $('div.video');

// define click function
$('a').on('click', function( e ) {

    // define var link
    var link = $(this).attr('href');

    // Add loading text
    $('.wrap').append('<span class="load">Loading text...</span>');

    // load content into video
    video.load( link + ' .content' );   

    // prevent default href action
    e.preventDefault();

}); 

Thanks for the help. Cheers

Upvotes: 0

Views: 160

Answers (1)

alex
alex

Reputation: 490453

This ought to do it.

video.load( link + ' .content' , function() {
    $('.wrap .load').remove();
}); 

Upvotes: 1

Related Questions