javascript - jQuery - Using .slideToggle and .animate simultaneously -
i have portion of jquery doesn't seem working correctly. have link click, [show/hide] should slidetoggle div. @ same time, want animate page scrolls top of div. works when put animate function inside slidetoggle function, in jfiddle.
however, means div want slides out, , then page scrolls down. id set both happen simultatneously, tried in this jfiddle doesn't work. tried doing scroll animation first, slidetoggle, didn't work - there way implement also?? cheers!
$(document).ready(function () { $('.click_to_hide').click(function () { var visible = $('.hide_on_click').is(":visible"); $('.hide_on_click').slidetoggle(500); if (!visible) { $('html, body').animate({ scrolltop: $('.hide_on_click').offset().top }, 500); } }); });
Comments
Post a Comment