Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
Hi everybody. i have a problem. Please help me. my html file contain div (id="abc"). I want to when click button to website go to div (id="abc")...
Posted
Comments
Richard C Bishop 8-Apr-14 17:30pm    
It does not work that way. Id's are not URL's.
Sergey Alexandrovich Kryukov 8-Apr-14 17:34pm    
It's not clear and does not seem to make any sense.
—SA

i think you want to navigate inside page only. you can simply create an anchor tag and pass the id of the div where you want to navigate.


use below link for reference.


http://www.bloggersentral.com/2010/10/jump-to-section-or-part-on-same-page.html[^]
 
Share this answer
 
Comments
Sanket Saxena 9-Apr-14 1:50am    
Yes it will work ( for same page - internal linking)
It does not seem to make any sense, by the following reason: there is not such concept as "to go to div". You don't "go" anywhere.

The attribute id is used as an element identifier, unique in the HTML document. This is not the only way to obtain a DOM object or its wrapper. However, if it has to be the id, this is the way to find the DOM element in Javascript:
JavaScript
myElement = document.getElementById("abc");


See also the jQuery way (highly recommended):
http://api.jquery.com/id-selector[^],
all other selectors: http://api.jquery.com/category/selectors[^].

If you need to learn jQuery (highly recommended), please see:
http://en.wikipedia.org/wiki/JQuery[^],
http://jquery.com[^],
http://learn.jquery.com[^],
http://learn.jquery.com/using-jquery-core[^],
http://learn.jquery.com/about-jquery/how-jquery-works[^] (start from here).

—SA
 
Share this answer
 
in your div add a ,<a href="#" id="atag" />  ......


$nc('html, body').animate({
               scrollTop: $nc('#atag').offset().top - 200
           }, 800);

 
Share this answer
 
try this.. :)

HTML
<a href="#abc">Go to Div</a>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900