Quiz
- Is using jQuery the only way to modify the dom with JS?
No! There are built-in ways. In fact, that's how JQ works: it provides (IMHO) a better interface to those built-in ways. I think jQuery is more clear, concise, and consistent. But that's just my opinion.
Furthermore, the built-in ways are getting better (partly from adopting ideas from jQuery and other libraries), so jQuery will probably eventually be out of a job. But for now, I like it.
- I would like to talk more about jQuery's Flaw, and The Click Method.
jQuery's flaw is also my opinion. The flaw is just that it's perfectly happy with an empty set, which is sometimes really convenient.
But sometimes, that means that errors are harder to catch:a
So, I implemented a plug-in that I like (again, personal preference):
- I would like to talk more about The Click Method.
the
click
method attaches a function to a DOM element, telling the browser to invoke (run, execute) the function when the element is clicked.and then:
The function does the CSS modifications that are dark mode.
- can you talk more about why this is an error: $("h3events").click(turnEventsRandomColor());
Sure! We don't want to invoke the function now, maybe not at all! Instead, we want to give the function to the
click
method.What the erroneous code does is run the function and give the return value to the
click
method. - I was stuck between b and d for answer 4, can you touch up on why we do not want to use the extra parentheses (turnBlue()) I am still a little confused on that part?
This is very common. There's a difference between referring to a function and running it. We don't want to run it. We want to give it to someone else to run.
- the reading made sense / The reading was clear
Glad to hear it!