Cannot programmatically trigger jQuery click event

后端 未结 9 2246
心在旅途
心在旅途 2020-12-20 16:39

If I understand correctly, to programmatically trigger a jQuery click event attached to an object with a css class of my-button, you should be able to just do t

9条回答
  •  鱼传尺愫
    2020-12-20 17:19

    I don't know if cross-domain JSONP has something to do with it, however I must say that programmatically triggering a click event on a selector that has to do with an html link (...) doesn't work.

    I suspect it has to be some sort of browser policy, so as to block pop ups. Consider the fact that browsers, have a mechanism to track and block pop ups and mostly allow the user authorize a click action before the new link appears.

    If you could programmatically click a link via jQuery, redirection, popups and all that stuff would be easier to do, hence it's not possible. Just to be clear:

    Link1 you cannot trigger that.

    Link2 you can trigger an onclick here, because it doesn't contain href.

提交回复
热议问题