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.
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):
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.
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.
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.
Glad to hear it!