我有一个无序列表,其中可能有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