Scroll the page to an with a particular href with jQuery

When the user clicks a button, I want his browser to automatically scroll to an <a> with a certain href (let's call it "abc"). Ideally the scrolling would be nicely animated in some way.

-------------Problems Reply------------

Give a look to the jQuery.scrollTo plugin.

With that plugin you could simply:


Way simpler:

element_to_scroll_to = document.getElementById('anchorName2');

Even no need for jQuery ;)

You don't need any plugin.

scrollTop: $('a#abc').offset().top

Category:javascript Views:0 Time:2009-09-09

Related post

  • jQuery - fade out an element when scrolling the page, fade in when scrolling back to top 2011-05-20

    I have a fixed-position image that I would like to fade out when scrolling the page. I've written a rather basic jQuery script to do so, and I imagine it is not the most efficient because it is polling constantly on page scrolling. I was wondering if

  • JavaScript to scroll long page to DIV 2008-09-16

    I have a link on a long HTML page. When I click it, I wish a DIV on another part of the page to be visible in the window by scrolling into view. A bit like EnsureVisible in other languages. I've checked out scrollTop and scrollTo but they seem like r

  • In JQuery is there way for slideDown() method to scroll the page down too? 2009-01-23

    The slideDown applied to a div does the slideDown but doesn't scroll the page down and the div slided down div remains hidden from view. Is there a way to scroll the page down as well so the user can view the div? --------------Solutions-------------

  • Keep Side Navigation Fixed with Scrolling of page 2009-07-23

    I have a clients website - and they want the navigation on the hire pages (longer page) to still be there at when you scroll the page down. I've had a quick go (not live) with position fixed but in doing so it the leftside naviga

  • How do I make a move up and down when I'm scrolling the page? 2009-10-28

    How can I make a div element move up and down the page when the user is scrolling the page? (where that element is always visible) --------------Solutions------------- You want to apply the fixed property to the position style of the element. positio

  • How to scroll the page with rjs? 2010-04-28

    How can I scroll the page to a partial, which got inserted via rjs? page.insert_html :bottom, :comments, :partial => 'comment', :object => @comment --------------Solutions------------- You have to add a javascript method to your page and call i

  • how to scroll a page inside a qwebview? 2010-07-10

    I guess this should be a simple task: change a QWebView's content (it always contains several pages of stuff) then scroll the page back in the previous position: y = self.webView.setHtml(looong_htm

  • PageDown/Up and Home/End keys don't scroll the page when a position:fixed div is present 2010-10-20

    I have a page that has a position:fixed div at the top:0px and bottom:0px (making a header and footer). When either the header or footer has "focus", I am able to use PageDown, PageUp, Home, End, and Spacebar to scroll the page. But if I click within

  • Glitching whilst using CSS transitions/translate on iPad when scrolling the page 2010-10-25

    I've noticed whilst optimising animations for use on iPad using hardware acceleration, I seem to be coming across an issue that I haven't fully been able to resolve. If you are applying webkit transforms such as translate, although the animation runs

  • Building a scroll view page for iphone appliction 2011-03-09

    Im new to the iphone development, i need to develop a scroll view screen.i have done a screen design in interface builder,and i ran the program on the simulator but iam unable to scroll the page. Following steps i used to design the page inside inter

  • values in the text field are becoming null when we scroll the page in table view 2011-06-03

    hii every one i have created a data entry screen like this in which each row contains a text field here after entering data into the text field if we scroll the page which are all the text fields goesup(beyond the view) will set to null when it come

  • website scroll between pages 2011-06-08

    how can I build a website that scrolls between pages when a link is clicked? eg, I found a jquery plugin called serial scroll can this be used to scroll between webpages? ----------

  • Scroll the page when the footer dynamically grows 2011-07-15

    I have links within my footer, which when they are clicked, reveal hidden content. So they're just hidden <ul> elements which are shown using jQuery slideToggle(); The problem I'm having is when I do this, I then physically have to scroll the p

  • jQuery - How to scroll the page to a div if div dynamically moves? 2011-08-15

    Currently I am creating a website mainly using a mix of PHP, SQL, and JS. I use the JS to dynamically pull up new data using PHP and SQL. The current issue I am running into is that I have a button that when clicked will have the page scroll to the c

  • How to freeze a div panel as it reaches top of the window while scrolling a page 2011-09-15

    When you scroll a page down, the right/left panel including all blocks in the panels go up too. Some websites have a feature that after reaching the top of the website, one block in the right or left panel freezes and does not go up further. Is it do

  • DIV Overflow:scroll - disable page scroll whilst mouse is inside 2011-09-28

    Is it possible to disable the ability for the mouse wheel to scroll the page whilst it is inside a certain DIV. That way it can only scroll the div and not the page. JQuery libraries are installed so I imagine it would be something along the lines of

  • Scrolling a page to the top from an iframe (containing a gwt application) 2011-10-05

    There is a website which has an iframe including a web application. Let's assume that the application has a height of 1000px. At the bottom of the application (1000px) there is button. If the user presses the button, then the application changes its

  • Move image(using jQuery) when user scroll the page? 2011-10-13

    I have an image: <img title="<?php echo JText::_('AEROBOT_HELLO'); ?>" src="images/aerobot.png" id="aerobot" align="right" /> And I want to move the image (make it visible any time), when user scroll the page. I tried this code: var $scro

  • Making a slider scroll the page 2012-02-17

    I have an absolute positioned jQuery slider on my page. With it, I want to be able to click and drag to scroll the page. You can see it right now here: (The white one at the bottom) When you drag the slider at the

Copyright (C), All Rights Reserved.

processed in 0.142 (s). 11 q(s)