title: I have n list items. I need to get no of item which has class active
body: <p>I am working on a slider which changes the active class on click of next and previous, I want the nth child each time which has class active.
  e.g. in current scenario it should return 3</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;div class="my-list"&gt;
      &lt;ul&gt;
          &lt;li&gt;&lt;a href="#"&gt; list item&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#"&gt; list item&lt;/a&gt;&lt;/li&gt;
          &lt;li class="active"&gt;&lt;a href="#"&gt; list item&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#"&gt; list item&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#"&gt; list item&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#"&gt; list item&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#"&gt; list item&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>JavaScript</strong></p>
  
  <pre><code>function getCurrentItem() {
      var listItem = $(".my-list ul li");
      var items = [];
      for (i = 0; i &lt; listItem.length; i++) {
          items[i] = listItem;
          if($(items[i]).hasClass("active")){
              console.log("here: "+i);
          }
      }
  }
   getCurrentItem();
  </code></pre>