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
Laurence Cimosz
8,993 Pointsgetting the time onto a web page with html and javascript
code on the .js page
var today = new Date(); document.getElementById('time').innerHTML=today;
code on html page
<marquee behavior="scroll" bgcolor="yellow" loop="-1" width="30%"> <i> <font color="blue"> Today's date is : <strong> <span id="time"></span> </strong> </font> </i> </marquee>
I'm trying to get the date and time onto a web page. I used this code and it scrolls and just says the date is, and doesn't say the current date and time. What am I doing wrong? Thank you.
1 Answer
Jordan Hewett
9,437 PointsI just tried your code out and it worked for me. Maybe make sure the .js file src is correct in your html. I'm not sure what else unless I see the entire code.