treehouse : what would you like to learn today?
Web Design Web Development iOS Development

How to apply back to top link in get element by id function?

  • Im a little new to java/css/html, and recently coded my first site. I set up my portfolio site ( http://www.jonyablonski.net/ ) to allow for javascript to switch content, allowing for all material to be contain upon a single page using this function:

    function switchContent(pageNum) {
    document.getElementById("content").innerHTML = aryPages[pageNum];

    My question is, how do I code a 'back to top' link on necessary content when all the page info is contained within the javascript info, and not the body?
  • Well ultimately the source code does HAVE a <body> and <html> element. So if you can find where those get generated and give one or the other an ID value, any link that #links to that ID value will jump to the top of the page.
  • thanks chris!