开发者

jquery scrollTo refuses to work

开发者 https://www.devze.com 2022-12-29 07:29 出处:网络
ive read all the scrollTo questions and couldnt find the answer. im trying to use the scrollTo plugin for a simple horizontal scroll (the site is horizontally designed).

ive read all the scrollTo questions and couldnt find the answer. im trying to use the scrollTo plugin for a simple horizontal scroll (the site is horizontally designed).

im using the following code

$(document).ready(function() {
$('#contactlink').click(function(){
$.scrollTo("#conta开发者_如何学Python", {duration: 8000 });
});
});

as is obvious, contactlink is the anchor link while conta is the anchor where the window should scroll to.

i know im missing something very obvious, but as im a beginner with jquery, id appreciate all the help i can get. is there any way to debug the functioning of the plugin?

thanks

///edit///

based on XGreen's inputs, i tried: $(document).ready(function(){ $("contactlink").click(function(event) {$('html,body').animate({ scrollLeft: $('#conta').offset().left }, 8000); }) });

i should have mentioned. the "conta" anchor is to the right of where the link is. how much of a difference does that make? also, here is the code for the anchor i used, is it incorrect? Contact.


leave the plugin out. its just extra js you dont need.

use this:

$('html,body').animate({ scrollLeft: $('#conta').offset().left }, 8000);
0

精彩评论

暂无评论...
验证码 换一张
取 消