次のようなフォーム フィールドがあります。
<input name='task_complete_percentage[]' value='' onchange='' class='percent' id='task_complete_percentage[]' style='width:40px;' type='text' />
<input name='task_complete_percentage[]' value='' onchange='' class='percent' id='task_complete_percentage1" + counter + "' style='width:40px;' type='text' />
<input name='task_complete_percentage[]' value='' onchange='' class='percent' id='task_complete_percentage2" + counter + "' style='width:40px;' type='text' />
<input name='task_complete_percentage[]' value='' onchange='' class='percent' id='task_complete_percentage3" + counter + "' style='width:40px;' type='text' />
フィールドが動的に追加され、すべての値を合計したい。
$('[id *= "task_complete_percentage"]').change(function(){
$('[id *= "task_complete_percentage"]').each( function () {
console.log('test');
});
});
ただし、最初のフィールドのみが機能していますが、このようにすると、すべての値が表示されます。私が間違っていることは何ですか?
$("#addElement").click(function(){
$('[id *= "task_complete_percentage"]').each( function () {
console.log('test');
});
});