Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Do a pure JS Code about input element for a listen even

01 const input = document.getElementById('todo-input');
03 input.addEventListener('keyup', event => {
04   if (event.keyCode === 13 && event.target.value !== '')  {
06  }
07  });

On a main.js ,I wrote 7 lines for something, but showing wrong ,how can I know what' wrong ?I am using dreamwaver CS6

1 Answer

Steven Parker
Steven Parker
220,937 Points

There does not appear to be anything wrong with this code, but it's lacking any content in the function body so it won't do anything noticeable as-is. It also depends on the HTML component, and since that part is not shown here it's still possible to have an issue there.

But if I add some appropriate HTML and some code for the function, this performs exactly as I would expect.