title: Using element.click() to simulate a Button Click in Javascript
body: <p>I'm trying to write an extension for Opera that automatically sends specific chat messages. (Commands, to be exact.) For that, I want to enter the message into the textarea, simulate a button click to send the message and read the reply I get.</p>
  
  <p>I've been trying to use the Element.click() function of JavaScript to simulate the click, but it doesn't work.
  My code goes something like this:</p>
  
  <pre><code>document.getElementsByClassName("text-area")[0].value = "test";
  document.getElementsByClassName("send-chat-button")[0].click();
  </code></pre>
  
  <p>The textarea gets filled in with the value I want, but it doesn't click the button.
  I am also not getting any output on the console. I'd be glad about any help I can get.</p>
  
  <p>Regards, Kileraptor1</p>
  
  <p>UPDATE: You were right, the button does not have an <code>OnClick</code> event like I thought it had. I'm honestly not sure how it submits a message. Since I am writing a plugin for a <a href="http://twitch.tv" rel="nofollow">website</a> I do not own, I can not edit the source or anything.</p>