title: Javascript: Automatically clicking a button?
body: <p>I'm learning how to write a chrome extension, and I'm fairly new to javascript.</p>
  
  <p>Here's some html:</p>
  
  <pre><code>&lt;div class="button data" style=""&gt;
     &lt;a class="button1 whiteColor" href="http://link1.com"&gt;VIEW This&lt;/a&gt;
     &lt;a class="button2 redColor" href="http://link2.com"&gt;VIEW That&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>What I want to do is open link2.com by automatically clicking button2 using javascript.</p>
  
  <p>I'm using the following, but it's not working :/ </p>
  
  <pre><code>document.getElementByClassName("button2 redColor").click();
  </code></pre>
  
  <p>Any help would be appreciated!!</p>