api.jquery.com icon indicating copy to clipboard operation
api.jquery.com copied to clipboard

Documentation about `trigger()` unclear about calling native event

Open SimonHeimberg opened this issue 6 years ago • 2 comments

Description

Does $('a#id77').click() open the link of <a>? Reading https://api.jquery.com/trigger/, I am not sure if native event is called, but I guess so. But at least, it does not. There is also a stackexchange discussion: https://stackoverflow.com/questions/5811122/how-to-trigger-a-click-on-a-link-using-jquery Please update the documentation to clearly mention if native events are triggered. And if necessary, fix any bug.

Link to test case

The link is not shown when doing a jquery click: https://jsbin.com/jifulaweqa/1/edit?html,js,output

SimonHeimberg avatar Nov 06 '18 15:11 SimonHeimberg

We have never triggered .click on anchor tags because not all of our supported browsers had this method available, which would have made the behavior inconsistent. However, I'm surprised I don't see mention of this in the docs.

timmywil avatar Nov 06 '18 16:11 timmywil

Thanks. This agrees with https://learn.jquery.com/events/triggering-event-handlers/

So my request is to update the documentation. I still am irritated what the term "native event" refers to, and why event.preventDefault() is mentioned when default is not run.

By the way, is it expected that the native click event is called for a parent <a> element? This seems to happen according to https://stackoverflow.com/a/21334234

SimonHeimberg avatar Nov 07 '18 09:11 SimonHeimberg