Results 1 to 3 of 3

Thread: Code to scroll to javascript element.

  1. #1
    Join Date
    May 2008
    Posts
    20

    Code to scroll to javascript element.

    Hi,

    I want to know some code to go to a particular element of javascript using scroll.

  2. #2
    Join Date
    Oct 2008
    Posts
    24

    Re: Code to scroll to javascript element.

    Try this code:

    Code:
      function jumpto(id){
          if((obj = document.getElementById(id)) && obj != null){
              window.scrollTo(0, obj.offsetTop);
          }
      }
    I hope this helps

  3. #3
    Join Date
    Apr 2008
    Posts
    61

    Re: Code to scroll to javascript element.

    Try this code:

    Code:
       
          $('a[href=#target]').
          click(function(){
          var target = $('a[name=target]');
          if (target.length)
          {
          var top = target.offset().top;
          $('html,body').animate({scrollTop: top}, 1000);
          return false;
          }
          });

Similar Threads

  1. javascript get element by class
    By GlassFish in forum Software Development
    Replies: 5
    Last Post: 06-03-2010, 09:05 PM
  2. How to set the value of a form element using Javascript?
    By shivendra in forum Software Development
    Replies: 4
    Last Post: 07-02-2010, 05:04 AM
  3. Using scroll for div element
    By garfield1 in forum Software Development
    Replies: 3
    Last Post: 01-07-2009, 10:52 PM
  4. JavaScript - How to create Element
    By Xylina in forum Software Development
    Replies: 3
    Last Post: 04-06-2009, 05:06 PM
  5. How do I know the width of an element through javascript?
    By Conner in forum Software Development
    Replies: 3
    Last Post: 06-04-2009, 11:29 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,435,918.60041 seconds with 17 queries