0
我有幾個div點擊時顯示不同的圖像,然後5秒後淡出。只有當我每次點擊一個div時,我都希望這個數字得到重置。以下是我嘗試使用的代碼,但它不起作用。jQuery setTimeout重置?
var showServicesDelay = function() {
timeoutHandle = setTimeout(function() {
jQuery(".services-inner").css({"opacity": "0.5"});
jQuery(".insignia-inner").css({"opacity": "1"});
jQuery(".insignia-inner-text").css({"opacity": "1"});
hideAll();
}, 5000);
};
var showMilitaryKit = function() {
jQuery(".military-kit-inner").css({"opacity": "1"});
clearTimeout(timeoutHandle);
};
var showProperty = function() {
jQuery(".property-inner").css({"opacity": "1"});
clearTimeout(timeoutHandle);
};
var showHomeContents = function() {
jQuery(".home-contents-inner").css({"opacity": "1"});
clearTimeout(timeoutHandle);
};
// military kit
jQuery(".military-kit-hover").click(function() {
hideAll();
hideServices();
showMilitaryKit();
showServicesDelay();
});
// property
jQuery(".property-hover").click(function() {
hideAll();
hideServices();
showProperty();
showServicesDelay();
});
// home contents
jQuery(".home-contents-hover").click(function() {
hideAll();
hideServices();
showHomeContents();
showServicesDelay();
});
+1 - 我會給予好評的是剪切速度,即***是***快! – adeneo
我希望取悅;) –