0

在我的 Jsp 中,值和类在循环中动态生成。

<div>
    <c:forEach var="interestTab" varStatus="loop" items="${interestParam}">
        <c:set var="interestFields" value="${fn:split(interestTab, '|')}" />
        <c:set var="maxAmt" value="${interestFields[1]}" scope="page" />
        <c:set var="minAmt" value="${interestFields[0]}" scope="page" />
        <c:set var="interestRate" value="${interestFields[2]}" scope="page" />
        <div class="personalcal-${loop.index}" style="display:hidden;">
            <div class="minamount-${loop.index}">
                ${interestFields[0]}
            </div>
            <div class= "maxamount-${loop.index}">
                ${interestFields[1]}
            </div>
            <div class= "intrate-${loop.index}">
                ${interestFields[2]}
            </div>
        </div>
    </c:forEach>

</div>

我想获取 jquery 中的所有值我该怎么做?如果它不是动态生成的类或 id,那么我可以简单地通过 $(".class").text() 获取它。但是现在我的班级正在随着循环而改变我怎么能得到它?

4

1 回答 1

1
put the below line in your jsp
<input type='hidden' value='${fn:length(interestParam)}' id="interestParamCount"/>

here is how to iterate in your js file

  for(counter = 0 ; counter < $('#interestParamCount').val();counter++){
      alert($('.minamount-'+counter).text());
      alert($('minamount-'+counter).text());
      alert($('intrate-'+counter).text());
  }
于 2013-11-06T07:52:27.640 回答