title: Add a class to first div using jQuery
body: <p>How to add a class to first div using jQuery. </p>
  
  <p>I Tried following code but doesn't work for me.
  maybe I'm missing something.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script src="http://code.jquery.com/jquery-1.8.2.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script&gt;
  $('.item')
      .eq(0).addClass('first').end()
      .eq(-1).addClass('last').end();
  &lt;/script&gt;
  &lt;style type="text/css"&gt;
  .first, .last{
  background-color:#0099FF;
  }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="item"&gt;aaa&lt;/div&gt;
  &lt;div class="item"&gt;bbb&lt;/div&gt;
  &lt;div class="item"&gt;ccc&lt;/div&gt;
  &lt;div class="item"&gt;ddd&lt;/div&gt;
  &lt;div class="item"&gt;eee&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Edit: Thanks to everyone, is there anyway to add a class to rest of DIVs?</p>