Reputation: 746
I have a quick question. I have a div that is hidden on page load. When a user toggles the div i use Jquery animate to open the div which is placed below the anchor div and is out of view. Is it possible to scroll to the top or slightly into the newly opened div once the animation starts? Also the div animates horizontally right now and thats what i want.
jquery
$('.specialOfferText').click(function() {
$('.offerPanelTab').animate({
width : 'toggle'
});
})
Upvotes: 1
Views: 62
Reputation: 56549
Since you mentioned scroll along with animation, there is an option in .animate()
for scrollTop
so you can achieve it. Try the below code
$('.specialOfferText').click(function() {
$('.offerPanelTab').animate({
scrollTop: "add your pxs",
width : 'toggle'
});
})
Upvotes: 1