0
有沒有辦法在我的網站上的某個div內加載任何圖像時,使用Jquery附加加載gif?我想它是一個全局函數,我似乎可以做到這一點的唯一方法是使用jQuery來調用某個鏈接,然後加載loading.gif
但這在我的情況下不起作用...JQuery全局加載動畫
指數HTML:
<div id="content">
<div class="projectThumb">
<img src="/img/aeffect_button_static.gif" name="aeffect" />
<p class="title">title</p>
</div>
</div>
<div id="popupContainer"></div>
稱爲HTML:
<div class="projectPopup" id="aeffect">
<a class="close">Close ×</a>
<img src="/img/aeffect_popup.jpg" width="500" height="729" alt="" />
<p class="description">Description</p>
</div>
JQuery的:
$(document).ready(function() {
//Find & Open
$(".projectThumb").click(function(){
$("#backgroundPopup").show();
htmlName = $(this).find("img").attr("name");
$("#popupContainer").load("/content/" + htmlName + ".html", null, function(){
//Set Variables
var container = $(".projectPopup")
var popupWidth = container.find("img:first").width()+10;
var popupHeight = container.find("img:first").height()+60;
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
//Set popup dimensions
container.css("width" , popupWidth);
container.css("height" , popupHeight);
//Set popup CSS
container.css({"position": "absolute", "background": "#000", "top": "5%", "left": (windowWidth/2) - (popupWidth/2) + "px", "z-index": "2" });
});
});
//Close property
$("a.close").live("click", function(){
$("#popupContainer").empty();
$("#backgroundPopup").hide();
});
});
在此先感謝