点击动作,我有一些功能是这个样子:重新启动功能使用jQuery
var live_search_list = $('.live_search_list ul'),
active_search_element = live_search_list.find('li.active'),
search_element = live_search_list.find('li'),
jsPane = $('.jspPane');
$('.bottom_search').click(function(){
if (!search_element.last().hasClass('active')) {
active_search_element.removeClass('active');
active_search_element.next('li').addClass('active');
jsPane.animate({top:"-=95px"});
}
});
$('.top_search').click(function(){
if (!search_element.first().hasClass('active')) {
active_search_element.removeClass('active');
active_search_element.prev('li').addClass('active');
jsPane.animate({top:"+=95px"});
}
});
所以,问题开始第一次点击之后,我只有一个动作 - 这个动画。第一次点击功能后,不再检查我的情况,并且不会更改,删除类active
。每次点击这个按钮后我怎样才能重新启动这个功能?
你想['停止()'](http://api.jquery.com/停止/)动画? – epascarello
我想在每次点击后检查我的情况,现在在第一次点击一切正常后,但在它之后我只有动画动作... – Lukas
您确定'search_element'和'active_search_element'是第二次和以后的有效元素点击? +1对于epascarello所说的 - 除了任何东西 - 在再次开始动画之前停止()总是个好主意,否则,如果用户在短时间内点击几次,你的动画就会排队等候,一切都会变得很诡异。 – WTK