I am using this bit of code to open a div and scroll down to it. It works well, but only the first time I use it, even on page refresh it will not work again. Does anyone know why this is happening? Thanks in advance!
Here is the URL(http://www.patrickorr.ca)
$(document).ready(function() {
$("div.ftropen")
.click(function(){
$("div#connect").animate({height: "500px" }, "fast");
$("div#ftrconnect").fadeOut("fast"); //hide connectbtn
$("div#ftrhide").fadeIn("fast"); //show hidebtn
$("#connect").scrollTop($("#connect").scrollTop() + 500);
return false;
});
$("div.ftrclose")
.click(function(){
$("div#connect").animate({height: "0px" }, "fast");
$("div#ftrhide").fadeOut("fast"); //hide hidebtn
$("div#ftrconnect").fadeIn("fast"); //show connectbtn
return false;
});
});
There seems to be a problem with the
jquery.anchor.jslibrary that is giving meUncaught TypeError: Cannot read property 'top' of null jquery.anchor.js:32in Chrome 14. I have commented it out and replaced the open function with:that scrolls the body to the top of the
<div id="connect">I’ll see if I can get the anchor animate plugin working…Actually the Anchor Slider plugin seems to be interfering with your
<div>click events completely. The<a>click is occurring first and consuming the event. I think that you need to decide to use the Anchor Slider plugin to animate the “scroll to” or the jQuery animate() in your code.Edit: If you remove the
jquery.anchor.jsscript, use the following targetand this JavaScript:
which animates the scroll to the
<a id="target">when the<div>height animate has completed.Edit2: Added a demo.