I have some function which is look like this:
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"});
}
});
So, problems starts after the first click, I have only one action - this with animation. After first click function is not checking my condition again, and not changing, removing class active
. How can I restart this function after every click on this buttons?