jQuery(".event_item .event_title").each(function(){
jQuery(this).click(function(){
var checkElement = $(this).next();
if(checkElement.is(':visible')) {
checkElement.parent().find(".event_content").slideDown().slideUp('normal');
}
if(!checkElement.is(':visible')) {
$(".event_item .event_title").parent().find(".event_content").slideUp('normal');
checkElement.parent().find(".event_content").slideDown('normal');
}
var elID = jQuery(this).parent().attr('id');
var fId = '#'+ elID;
scrollTo = $(fId);
jQuery('html, body').animate({scrollTop:jQuery(fId).position().top }, 500);
});
});
The scrolling behavior is not consistent. It works fine for the first item, but subsequent clicks do not scroll properly. I want each click to smoothly scroll to the top so that users can easily view the content they opened.