The jquery code below will hide divs ending in -value-wrapper when the page loads. My problem is that the Add More button will add another line (with an increased number). When this happens, all divs are expanded. Is there a way to keep the original hidden ones and hide them in a new set?
The html markup is as follows:
<div id="group-information-items">
<fieldset>
<legend>Member Information</legend>
<label>Form label 1</label>
<table>
<tr>
<td>
<div class="form-radios">
<input type="radio" class="form-radio" checked="checked" value="0" name="gci[0][fa][value]" id="edit-gci-value-0"> A
<input type="radio" class="form-radio" value="1" name="gci[0][fa][value]" id="edit-gci-value-0">B
</div>
<div id="edit-gci-0-fa-list-value-wrapper" class="form-item">
<label>List: </label>
<textarea name="gci[0][fa_list][value]" rows="5" cols="60"></textarea>
</div>
</td>
</tr>
</table>
<div class="content-add-more clear-block">
<input type="submit" value="Add more values" id="edit-gci-add-more" name="gci_add_more">
</div>
</fieldset>
</div>
The code that performs the initial hide is below:
$("#group-information-items div").each(function() {
$("div[id$='-value-wrapper']").each(function() {
$(this).hide();
});
});
source
share