Reputation: 33
i have this jquery code which successfully uses slideToggle
to open and close a div below.
$('#map-wrap').slideUp("fast");
$('#get-here-btn').click(function() {
if (!$("#map-wrap").is(":visible"))
$('#get-here-btn').addClass("active").html('Close');
$("#map-wrap").slideToggle("fast","linear",function() {
if (!$("#map-wrap").is(":visible"))
$('#get-here-btn').removeClass("active").html('How to get here');
});
});
i'd like to scrollTo
the now-open div once it's open (with some sort of easing). i've tried a few variations and i can only get it to jump to the location (is this because the element is hidden when the button is clicked?) rather than slide.
i know i should probably add the scrollTo into the slideToggle function but am not sure where?
any help much appreciated. thanks in advance, Leon
i've knocked up a JSFiddle: http://jsfiddle.net/leonharris/rZqwx
Upvotes: 1
Views: 760