Skip to content

Instantly share code, notes, and snippets.

@sosroInSpace
Created February 8, 2018 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sosroInSpace/3de3e934b5fa43529d3375f80be0d059 to your computer and use it in GitHub Desktop.
Save sosroInSpace/3de3e934b5fa43529d3375f80be0d059 to your computer and use it in GitHub Desktop.
small function for reference - show background image after it has finished loading.
/* //////// SHOW HEADER BACKGROUND IMAGES ONCE PAGE LOADS /////////*/
$(function(){
/* div container image store in variable */
var $div = $('.home .topHeadForNavBar'),
/* store background image css property as variable */
bg = $div.css('background-image');
if (bg) {
var src = bg.replace(/(^url\()|(\)$|[\"\'])/g, ''),
$img = $('<img>').attr('src', src).on('load', function() {
// do something, maybe:
$div.animate({opacity: '1'}, 1000);
$('.looadingHome').fadeOut();
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment