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 trial
Steven Rayzman
2,423 PointsHow To Get Current Date
Using JavaScript how can I get the current date, as well as the one two days in advance? So I would want to get something like January 1, January 3.
2 Answers
John Magee
Courses Plus Student 9,058 PointsStart here
John Magee
Courses Plus Student 9,058 PointsSteven
Take a look at your code - realize what your variable definition is covering...
Steven Rayzman
2,423 PointsSteven Rayzman
2,423 Points@john Magee Alright, I've figured it out, thanks. But how can I set the value of a header to the value of a javascript value?
John Magee
Courses Plus Student 9,058 PointsJohn Magee
Courses Plus Student 9,058 Pointshttp://www.w3schools.com/jsref/met_element_getelementsbytagname.asp
Though i'd use an ID or name assigned to the header you want to change, and then look up .innerHTML
Steven Rayzman
2,423 PointsSteven Rayzman
2,423 PointsI have tried the code above, but the button that I click to display the information does not even show up. @johnMagee
Steven Rayzman
2,423 PointsSteven Rayzman
2,423 PointsFirst off thank you so much for all the help. I think it covers the document, so does that only mean the document that contains the code? If so how would I reference the html document? @johnmagee
John Magee
Courses Plus Student 9,058 PointsJohn Magee
Courses Plus Student 9,058 PointsSteven - you're asking questions that would be covered in the right JS couse if you had made it to the point of changing content and learning about it.
The DOM (Document Object Model) is a key principle to understanding how to capture specific parts of a web page and how to manipulate them (be it all one selector, or all one class, or on specific element because of it's ID).
What you should do on your example code that you submitted is write it out the long way - shownDate.getElementById("shownDate") --> what when you write out shownDate in its entirety?
Steven Rayzman
2,423 PointsSteven Rayzman
2,423 PointsI really do not currently understand what you mean by writing it out the long way? @johnMagee