Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialShams Nelson
2,888 PointsHow can I get a link to the same page to scroll to the content
When something like <a href="#bottom_content"> is used to link to a div at the bottom of the same page, how can I have that page scroll to that location instead of teleport (for lack of a better word) there?
4 Answers
Kevin Korte
28,149 PointsYou need Javascript to do this.
I have never used, nor did I know much about this plugin, but it came up first on a google search, so use at your own risk.
Ana Cristina Patiño Aguirre
4,644 PointsOk, If I have understood correctly, try addeding an id to the div and use the id's name as value to the href attribute like this
<a href="#nameofthediv">Link to the div</a>
<div id="nameofthediv">Content</div>
Kevin Korte
28,149 PointsAs I understood it, it sounds like he already has that working, because he asked how to make the page scroll there, instead of just jump right to that div, as this basic set up would.
Ana Cristina Patiño Aguirre
4,644 PointsOh, my bad, now I get the "teleport" part lol
Shams Nelson
2,888 PointsPerfect, thanks!
And sorry bout the confusion :)
Shams Nelson
2,888 PointsJust used this and it works great. Very simple and clean to set up as well. Thanks again.
~Shams