0

I'm trying to programmatically click the "listen" button on a Google Translate page (https://translate.google.com/#en/es/javascript)

For some reason this code does not produce a sound:

document.getElementById('gt-src-listen').click()

while actual clicking on the button does.

Why these two are not identical and how can I programmatically emulate a click in this case?

  • See this: [answer](https://stackoverflow.com/questions/906486/how-can-i-programmatically-invoke-an-onclick-event-from-a-anchor-tag-while-kee). Seems like it is addressing the same problem. – K. Kirsz Jun 30 '17 at 18:41

1 Answers1

-1

If you are using vanilla javascript I think the event you are trying to use is onclick, You can see the difference between the both of them in this SO answer What's the difference between "click" and "onclick" when creating an element with jQuery?

Isaac Osiemo
  • 116
  • 1
  • 9