How to simulate a click on a element which also results in invoking attached events?
My开发者_JS百科 test case is @ Gmail, I am trying to simulate a click to open the first e-mail with JavaScript.
Actually I did a successful attempt which is done by firing a mousedown event.
But I wonder if there is a generic method to generate "organic" clicks instead of me wasting time on investigating attached events ?
You can just trigger the usual suspects...but other than that, there's no good generic way to simulate a native click from a user (and an actual native click is impossible, for example making an <a>
go to it href
, without doing the redirect yourself).
Triggering the relevant events to a click
for something like gmail would look like this:
$(selector).mousedown().mouseup().click();
精彩评论