Capitalize first letter using javascript
<p>I'm trying to capitalize first letter of sentence for every class.</p>

<p>I have html <code>&lt;span class="price"&gt;&lt;/span&gt;</code> multiple time on my page and I want to capitalize first letter of every tag. So I have an array of span classes.</p>

<p>Default value of html elements is lowercase, I tried with text-transform:capitalize, it converts first letter of every word. </p>

<p>I tried to write some code but it doesn't work, it goes through loop only once and it doesn't work.  </p>

<p>Here is the code, can somebody help me to modify to work</p>

<pre><code>function applySentenceCase() {
    var selector = document.getElementsByClassName('price');
    for( i =0; i&lt;selector.length; i++) {
      var selectorTest = jQuery(selector[i]).text();
      return selectorTest.charAt(0).toUpperCase() + selectorTest.substr(1).toLowerCase();

        }
    }
</code></pre>