jeudi 29 mai 2014

jQuery function failing


Vote count:

0




I have the following jquery code:



$(document).ready(function () {

// Click event for any anchor tag that's href starts with #content
$('a[href^="#content"]').click(function (event) {

// The id of the section we want to go to.
var id = $(this).attr("href");

// An offset to push the content down from the top.
var offset = 605;

// Our scroll target : the top position of the
// section that has the id referenced by our href.
var target = $(id).offset().top + offset;

// Smoothly scroll the page
$('html, body').animate({ scrollTop: target }, 500);

// Prevent the page from jumping down to our section.
event.preventDefault();
});
});


And HTML:



<a href="#content" onclick="return anchorJump('content');" hreflang="en-US"><span>Skip to Content</span></a>


So, here's the problem: the element with id="content" is above my link. And when I scroll the page so that the link is at the middle of it, clicking it will cause the page to scroll half the offset in a top direction, not bottom. Link to my website: http://ift.tt/1gF3vqW Try it. I think it's because of my version of jQuey Library: 2.1.1???



asked 48 secs ago






Aucun commentaire:

Enregistrer un commentaire