Get current value jstl foreach in jquery
<p>I want to know how to get the current value in an element of the loop <code>forEach</code> in JSTL, my code is :</p>

<pre><code>&lt;c:forEach var="mc1" items="${lstMedCon1}"&gt;
  &lt;div class="row" style="text-align: center;color:#186793;"&gt; 
    &lt;span id="idEspeciality" class="label label-default" style="background:#186793;font-size: 30px;"&gt;${mc1.strEspeciality}&lt;/span&gt;
  &lt;/div&gt;
&lt;/c:forEach&gt;
</code></pre>

<p>in javascript </p>

<pre><code>function goNext() {
   console.log($("#idEspeciality").text());
}
</code></pre>

<p>In my code the function <code>goNext()</code> is called for <code>setInterval(goNext, 6000)</code> and for each intervalue the text change in the view, so I want to get the current value in js but the same value is printed in console which is the first value of the list, but in the view the value is changed</p>