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.

JavaScript DOM Scripting By Example Adding and Removing Names Using the submit Event

Patrick Thomas
seal-mask
.a{fill-rule:evenodd;}techdegree
Patrick Thomas
Full Stack JavaScript Techdegree Student 2,810 Points

So, I am wondering do I need to delete the submitButton element?

I have tried deleting and replacing the submitButton with the form element, but the code is still not working. I need some help with this problem?

app.js
const form = document.querySelector('form');
const submitButton = form.querySelector('type=Submit');

submitButton.addEventListener('submit', () => {  
});
index.html
<!DOCTYPE html>
<html>
<head>
  <title>Submit Event</title>
</head>
<body>
<form>
  <label>Name:</label>
  <input type="text" name="name">
  <input type="Submit" name="submit" value="Submit">
</form>
  <script src="app.js"></script>
</body>
</html>

1 Answer

Steven Parker
Steven Parker
216,810 Points

The system should have given you this hint:
ā€ƒ Bummer: You didn't use addEventListener on the form

That's a hint that the "submit" event should be listened for on the form instead of the button.