code_junkie

delaying the loading of a certain css background image

Nov 14th, 2011
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. ...
  2. #big-menu {
  3. background: #fff url(../images/big-menu.jpg) no-repeat;
  4. }
  5. #some-menu {
  6. background: #fff url(../images/some-menu.jpg) no-repeat;
  7. }
  8. #some-other-menu {
  9. background: #fff url(../images/some-other-menu.jpg) no-repeat;
  10. }
  11. ...
  12.  
  13. function loadBG(){
  14. document.getElementById("big-menu").style.backgroundImage="../images/big-menu.jpg";
  15. }
  16. window.onload=loadBG();
  17.  
  18. var imgGroup = new YAHOO.util.ImageLoader.group(window, 'load', 2);
  19.  
  20. $('firstElement').addClass('some-menu');
  21. $('secondElement').addClass('some-other-menu');
  22. $('lastElement').addClass('big-menu');
  23.  
  24. $('firstElement').css("background-image", "some-menu.jpg");
  25. $('secondElement').css("background-image", "some-other-menu.jpg");
  26. $('lastElement').css("background-image", "big-menu.jpg");
Add Comment
Please, Sign In to add comment