我有一個無序列表,其中可能有30個項目。當這些物品中的一個懸停時,剩餘的物品將褪色至30%,而懸掛物品則保持100%。當你從列表中移開時,它們都會褪去100%,我已經管理好了。jQuery淡入淡出/淡化其他列表元素,當我有一個懸停時,我在那裏90%..?
當您從一個項目移動到另一個項目時,其他列表項會逐漸回退到100%,然後回落到30%。除非用戶離開整個列表,否則我希望他們保持在30%。
我在每個列表項上使用hoverIntent插件。我還用jQuery爲當前列表項添加一個類,這樣我就可以淡化剩下的東西,並在你離開時刪除它。我在jQuery Cookbook站點上使用了一個等待函數(http://docs.jquery.com/Cookbook/wait)
你能找到我嗎?
這裏是我到目前爲止的代碼:
$.fn.wait = function(time, type) {
time = time || 300;
type = type || "fx";
return this.queue(type, function() {
var self = this;
setTimeout(function() {
$(self).dequeue();
}, time);
});
};
$("#sites li:not(#sites li li)").hoverIntent(function(){
$(this).attr('class', 'current'); // Add class .current
$("#sites li:not(#sites li.current,#sites li li)").fadeTo("slow", 0.3); // Fade other items to 30%
},function(){
$("#sites li:not(#sites li.current,#sites li li)").wait().fadeTo(600, 1.0); // This should set the other's opacity back to 100% on mouseout
$(this).removeClass("current"); // Remove class .current
});
*顯然,這是一個$(文件)。就緒內(函數()
誰能幫我請
非常感謝
你能贊成嗎?用此代碼提供測試頁面? – mkoryak 2009-04-17 13:06:07
在http://jsbin.com上設置了一個示例頁面,將其保存爲公共URL,然後在您的問題中鏈接到它 – 2009-04-17 13:14:46
我將立即在jsbin上設置它,謝謝。 – Zander 2009-04-17 13:21:23