「toggleClass」に問題があります。このスクリプトが行うことは、ラジオ ボタンの値に応じて新しいフィールド セットを追加することです。フィールド内には、デフォルトで非表示になっている新しい div があり、'a' がクリック イベントによってトリガーされた場合にのみ表示されます。最初は機能しますが、別のラジオ ボタンまたは同じラジオ ボタンをクリックすると、「toggleClass」が機能しなくなります。
コードは次のとおりです。
$(document).ready(function(){
$('.duplicatorRadio').click(function() {
var this_index_limit = parseInt($(this).val());
for(var i = 0; i < this_index_limit; i++) {
if(!$('#text_box_' + i).length) {
var headerValue = parseInt(i) + 1;
$(
'<fieldset id="text_box_' + i + '"> <h3>Property ' + headerValue +' Information</h3> <a class="borrowerToggler" href="#">Show Co-Borrower</a> <div class="borrower hide"> <h5>Co-Borrower Information</h5></div></fieldset>'
).appendTo($(this).parent());
}
else if($('#text_box_' + i).css('display') == 'none') {
$('#text_box_' + i).show();
}
}
$('fieldset').each(function() {
var split_id = $(this).attr('id').split('_');
if(!split_id.length) return;
var index = parseInt(split_id[2]);
if(index >= this_index_limit) {
$(this).hide();
}
});
$("a.borrowerToggler").click(function(){
$(this).next("div").toggleClass("hide");
});
});
});