Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What's the difference between click here and click here?


Asked by Penelope Arellano on Nov 30, 2021 FAQ



Click here. Click here. Click here. Click here. Click here. This list is useless to Colleen, but instead of merely reading back a couple of sentences to establish context, she’s going to have to listen to the entire page.
Additionally,
My guess is .click because it directly binds the JavaScript function to the property, thus allowing the site to load faster. To me click () sounds like a jquery method whereas onclick () is an event.
Consequently, No, there is no functional difference between the two code samples in your question. .click (fn) is a "shortcut method" for .on ("click", fn). From the documentation for .on (): There are shorthand methods for some events such as .click () that can be used to attach or trigger event handlers.
One may also ask,
'.click' requires the event handler to be attached to all elements that match the same selector. This results in needless overhead when the defined selector occurs in the DOM multiple times, because each of these elements needs to be bound and monitored to and by the event handler.
Just so,
When .on () is called without a selector parameter, it behaves exactly the same as .click (). If you want event delegation, use .on (). .on () is the recommended way to do all your event binding as of jQuery 1.7.