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 trialCrystal Morrison
11,076 PointsConsole error on my web site...
I am getting the following error when I upload the app.js and index.html from Exercise 2.
Uncaught SyntaxError: Unexpected token .
I tried with my own code, then I copied/pasted the code from the exercise:
app.js: const form = document.getElementById('registrar'); const input = form.querySelector('input');
form.addEventListener('submit', (e) => { e.preventDefault(); const text = input.value; input.value = ''; const ul = document.getElementById('invitedList'); const li = document.createElement('li'); li.textContent = text; ul.appendChild(li); });
html has line added: <script type="text/javascript" src="app.js"></script>
The error is on line 4: form.addEventListener('submit', (e) => {
Can anyone help?
Thanks, Crystal
3 Answers
Jonathan Grieve
Treehouse Moderator 91,253 PointsCode looks good to me.
When you copied the code across did you save first and refresh the browser?
Or is there a typo somewhere above the line 4? Sometimes when you get a console error it's actually referring to a problem somewhere above the line.
By the way, check out the Markdown Basics course on Treehouse, to help you post clearer code to the forums! :-)
Crystal Morrison
11,076 PointsI checked and rechecked the code to make sure -- then I started copying the code from the exercise. Nothing seemed to work. I have uploaded it to my website hosted by SiteGround:
http://crystalmorrison.net/javascript/
I will check out that Markdown Basics for the next time I post code :)
Jonathan Grieve
Treehouse Moderator 91,253 PointsHi Crystal, Thanks for providing the link :)
I'm not getting any console errors from that link and the submit button seems to be working! It looks to me like whatever the issue was that was coming up in the console has been resolved!
Crystal Morrison
11,076 PointsYou are right. I wish more problems would just fix themselves :)