我試圖用jquery創建一個簡單的網站http://cone.hostei.com/index3.html。我只想使用函數將html頁面加載到div中。問題是,功能 - $('.preloader').hide()
和({ opacity : 1 }
),火災之前,頁面及其圖像完全加載到一個div!我該如何解決它?Jquery加載頁面
$(window).load(function() {
$('li a').click(function() { //event on click
var toLoad = $(this).attr('href'); //get href of a li element
$('.load-in').fadeOut('fast', loadContent);
$('.loader').show(); //show the loader
function loadContent() {
$('.load-in').css({ //set opacity 0.3
opacity: 0.3
}).load(toLoad, hideLoad); //load html page, then callback
};
function hideLoad() {
$('.load-in').fadeIn('fast',
function() { //hide preloader and set opacity 1
$('.loader').fadeOut('fast');
$('.load-in').animate({
opacity: 1
});
});
};
return false;
});
});
你的問題不清楚。沒有冒犯性,代碼在你的頁面上結構也很差。要破譯你的意圖是非常困難的。 – 2013-04-10 02:47:35
您需要將相關代碼複製到問題中,而不僅僅是指向網頁的鏈接 – 2013-04-10 02:58:43