title: How do I simulate a click on a div with javascript
body: <p>I am looking for a way to be able to rig a shortcut to a youtube controll button. I want to be able to click on the left and right arrow to activate "Previous video" and "Next video" on a playlist. I used to be easily able to do it myself, but they made some changes and since those I can't quite replicate what i used to have working.</p>
  
  <p>I use the Google Chrome <a href="https://chrome.google.com/webstore/detail/shortkeys/logpjaacgmcbpdkdchjiaagddngobkck" rel="nofollow noreferrer">Shortkey</a> Plug-in to manage my short cut keys. I make the right key execute a javascript code only on "<a href="https://www.youtube.com" rel="nofollow noreferrer">https://www.youtube.com</a>*"</p>
  
  <p>The problem reside in the script to execute. I used to simply do a document.getElementById but now they use class instead of id and I cant get it to work. Their buttons are divs and they go like this:</p>
  
  <pre><code>&lt;div class="ytp-button ytp-button-prev" role="button" aria-label="Previous" tabindex="6050" style="display: inline-block;"&gt;
  &lt;/div&gt;
  &lt;div class="ytp-button ytp-button-next" role="button" aria-label="Next" tabindex="6051" style="display: inline-block;"&gt;
  </code></pre>
  
  <p></p>
  
  <p>My code actualy comes from another <a href="https://stackoverflow.com/a/6158050/1692889">Stackoverflow Question</a></p>
  
  <p>Still, if I put all of that together to make the folowing code it doesn't work.</p>
  
  <pre><code>simulate(document.getElementsByClassName("ytp-button ytp-button-prev"), "click");
  </code></pre>