Created
February 8, 2018 12:18
-
-
Save sosroInSpace/3de3e934b5fa43529d3375f80be0d059 to your computer and use it in GitHub Desktop.
small function for reference - show background image after it has finished loading.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* //////// 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