ボックスの順序で名前属性に変更入力番号に関する質問があります。最初のボックスで入力名を変更すると、ラジオ入力付きの2番目のボックスでチェック値が失われます。ラジオ入力の名前を変更 - ラジオが消えた
$('.container').find('.box').each(function (idx) {
$(this).find('input').each(function() {
let field = $(this);
let fieldName = field.attr('name');
let mIndex = 0;
if (fieldName.length !== 0) {
field.attr('name', fieldName.replace(
/\[\d+]/g,
function (match, pos, original) {
return mIndex++ === 0 ? '[' + idx + ']' : match;
}));
field.attr('id', field.attr('name').replace(/[\[\]]/g, '#').replace(/\#+/g, '-').replace(/[-]+$/g, ''));
field.closest('.field').children('label').attr('for', field.attr('id'))
}
});
はここでの例で私のコードです:https://jsfiddle.net/pbLkabhe/
私の質問は、無線入力が変更入力名の後に値を確認滞在するJavaScriptコードを修正する方法です。
私はあなたの形式のいずれかの障害が表示されません。 –
2番目のボックスにはラジオ入力オプションが表示されません(http://prntscr.com/fl5794) – Matt