views:

132

answers:

1

hey,

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", {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.

A: 

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

use this:

$('html,body').animate({ scrollLeft: $('#conta').offset().left }, 8000);
XGreen
He said **horizontal** scroll...
Nick Craver
apologies. updated the answer now
XGreen
thanks for the help. but the code didnt work. this is how 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? <a name="conta" id="conta">Contact.</a>
hasan
why do you want to scroll to an element that is already next to its trigger link and already visible?
XGreen
i think theres been a mistake in the way ive said it. the anchor is not next to the trigger link. its 800 pixels away. (to the right if it matters)
hasan
ok, so, i feel very stupid right now. after copying XGreen's code, i typed it out and missed out a # for the id. after correcting that, its working fine. thanks a lot Xgreen for your help.
hasan