javascript - Cannot fire a mousedown event with jquery -


i'm trying simulate click event in http://translate.google.com jquery. purpose, loaded jquery file code:

var script = document.createelement("script"); script.src = "http://code.jquery.com/jquery-1.10.1.min.js"; document.body.appendchild(script); 

then i'm trying simulate click on element selector, this:

jquery(".goog-inline-block.goog-flat-menu-button-caption").trigger("mousedown") 

i tried click event instead of mousedown:

jquery(".goog-inline-block.goog-flat-menu-button-caption").trigger("click") 

none of them gives effect of manually clicking div, namely opening new div. attached ss of desired behaviour.

clicked state

what can cause jquery not working? or how can simulate effect in other ways?

edit: adding jquery seems successful in sense can use jquery method select elements , change contents of them etc.

the solution creating mouseevent , dispatching element, this:

var e1 = document.createevent("mouseevents"); e1.initmouseevent("mousedown", true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null); jquery('#gt-sl-gms')[0].dispatchevent(e1) 

it seems jquery's event mechanism uses different dispatching system, since can not trigger listener function, though didn't confirm info.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -