title: Changing a div's style when clicked, and changing it back when another div is clicked
body: <p>I have a number of divs with the class <code>trashitem</code> within a .hta file. Upon clicking a particular div I need to change its border to 3px and red. When a different div is selected, I need the original div to revert back to its original style (1px black border) and <strong>ALSO</strong> change this second div's border to 3px red.</p>
  
  <p>Basically only one div can be red at a time.</p>
  
  <p>Pure JavaScript is preferred over jQuery please. I'm assuming I need to apply a class to the clicked div, and remove it from this class if another div is chosen, while adding this second div to the class or something?</p>
  
  <p>All the divs have the class <code>trashitem</code> but they each are referencing a unique function onclick, see below:</p>
  
  <pre><code>&lt;div class="trashitem" onclick="Writedata13()"&gt;
     &lt;div class="photobox"&gt;
        &lt;img src="http://www.fakeImage.JPG"&gt;
     &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="trashitem" onclick="Writedata14()"&gt;
     &lt;div class="photobox"&gt;
        &lt;img src="http://www.fakeImage.JPG"&gt;
     &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="trashitem" onclick="Writedata15()"&gt;
     &lt;div class="photobox"&gt;
        &lt;img src="http://www.fakeImage.JPG"&gt;
     &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>UPDATED CODE</strong></p>
  
  <hr>
  
  <p>JAVASCRIPT</p>
  
  <pre><code>&lt;script language="javascript"&gt;
  function Writedata14(event)
  {
   var a = event.target;  
   a.style.cssText = 'width:330px;height:10px;background-color:black';  
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>&lt;div class="trashitem" onclick="Writedata14()"&gt;
      &lt;div class="photobox"&gt;
          &lt;img src="http://www.fakeImage.JPG"&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="trashitem" onclick="Writedata15()"&gt;
      &lt;div class="photobox"&gt;
          &lt;img src="http://www.fakeImage.JPG"&gt;
       &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Link to <a href="http://codepen.io/anon/pen/LVvvME" rel="nofollow">Codepen demo: http://codepen.io/anon/pen/LVvvME</a>.</p>