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 trialjason limmm
8,009 Pointsqueryselect error
document.querySelector("button[type="button"]").addEventListener('click', req());
anything wrong with my queryselector, i can't seem to find the problem
<button type="button">no block i think</button>
here is the html
1 Answer
Steven Parker
231,275 PointsIt helps to know what course and lesson you are referring to, and to be able to see your code. You might want to take a look at this video about Posting a Question. And you may also want to view this one about sharing a snapshot of your workspace.
But putting a quoted term inside other quotes of the same kind causes the term to be taken as an identifier. You can see from the syntax coloring in the first line that the word button is not part of the quoted string. Use a different token (such as apostrophe) for the quotes inside the other quotes (or in this case you can omit them entirely).
Also, unless "req" is a function that returns another function, it probably should not have parentheses after it. As it is, what's being passed is the result of calling "req" instead of a reference to the function itself.
jason limmm
8,009 Pointsjason limmm
8,009 Pointsoh ok, here is the snapshot, https://w.trhou.se/0nrglfo27f
Steven Parker
231,275 PointsSteven Parker
231,275 PointsMy guess was right about those first 2 issues. Applying my suggestions would give you this:
But it also looks like the syntax inside the function is a bit off. Â So instead of this:
()=>{setTimeout(document.getElementById("jsinsertion").innerHTML="ok ty", 8000)};
… you probably want this: