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

JavaScript Interactive Web Pages with JavaScript Traversing and Manipulating the DOM with JavaScript Perform: Changing Classes

見綸 陳
見綸 陳
6,333 Points

About the querySelector

In the editTask function

When we set the variables to get element, here is the part of codes

---
var editInput = listItem.querySelector("input[type=text");

---
Why here we miss a '' ] " in the ("input[type=text"); ?
jason chan
jason chan
31,009 Points

Hey Jian, you can use three back ticks to format code. it's near the 1 on the keyboard. 3 back ticks plus language so

-```html

code inside

plus``` to close

del - and plus

But i fixed it.

3 Answers

Steven Parker
Steven Parker
229,005 Points

Apparently, the closing bracket is optional! But this is not a recommended practice (or even an acknowledged feature, as far as I can tell from the docs).

My recommendation is to forget you ever saw this.   :see_no_evil:   Or, you might want to report it to Treehouse Support as a bug in the video and downloads (and then forget it).

Jose Balaguer
Jose Balaguer
17,473 Points

Yes, he should write the closing "]". I think the code works because the part in between "..." is a string. And the method search into the existent code, the string you pass inside the method. So, the string "input[type=text" is found in the code, as well as "input[type=te" will be found and even "input[type=t". If the error was something like "input[type=tex]" then this will cause an error, because this string doesn't exist in the document. The code not causing error, in this particular case, doesn't mean it's well written.

jason chan
jason chan
31,009 Points
var editInput = listItem.querySelector("input[type=text]");