Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 04-07-2009
Member
 
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.
Reply With Quote
  #2  
Old 04-07-2009
Member
 
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
Reply With Quote
  #3  
Old 04-07-2009
Member
 
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;
      }
      });
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 09:42 PM.