当我单击按钮时,我试图显示隐藏的 div,然后每次用户单击按钮时都会显示更多索引。
那是行不通的,因为如果我处于添加模式而不是编辑(编辑时显示 div),列表上总是空的
<li>
<button type="button" name="addAnotherButton" class="btnFwd gradient smButtonStyling"
onClick="showInput();">
<img src="/Common/web/static/images/add.png" class="smbtnIcon" />
Add Another
</button>
</li>
<li>
<c:forEach items="${planInfoList}" var="planInfo" varStatus="status">
<div id="uploadBody[${status.index}]" style='display = none'>
<label class="adminFormLabel">Title:</label>
<form:input path="planInfoList[${status.index}].title" onfocus="this.select();" maxlength="50" size="30"/>
<label class="adminFormLabel">Plan Number:</label>
<form:input path="planInfoList[${status.index}].planNumber" size="10" maxlength="10"/>
</div>
</c:forEach>
</li>
JS:
var found = 0;
if ($('#uploadBody' + i).hide()) {
for (var i = 0; i < 5; i++) {
if (found == 0) {
$('#uploadBody' + i).show();
}
found++;
}
}