title: How I can get the index of class(css) array
body: <p>How can I get the index,
  <code>document.getElementsByClassName(&quot;selected&quot;)[i].css(&quot;background-color&quot;, &quot;green&quot;);</code> is not working</p>
  <pre class="lang-js prettyprint-override"><code>$(function(){
      $(&quot;#but&quot;).click(function () {
          var corr = $(&quot;.lblcorrectans&quot;);
          var selected = $(&quot;.selected&quot;);
  
          for (var i = 0; i &lt; model.length; i++) {
              if (corr[i].innerHTML == selected[i].innerHTML) {
                  document.getElementsByClassName(&quot;selected&quot;)[i].css(&quot;background-color&quot;, &quot;green&quot;);
              }
              else {
                  document.getElementsByClassName(&quot;selected&quot;)[i].css(&quot;background-color&quot;, &quot;red&quot;);
              }
          }
      });
  });
  </code></pre>