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 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,008 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
218,679 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,008 Points
var editInput = listItem.querySelector("input[type=text]");