これで、.val()を呼び出すと値が見つからない動的なテキストボックスがいくつか生成されています。ページの読み込み時にレンダリングされたテキスト入力は.val()で値を返しますが、残りはすべて戻りません。動的に生成されたテキスト要素からval()を取得します
この例では答えが得られない場合は、実際のコードで質問を編集しますが、正確に簡略化するために全力を尽くしました。
はJQuery:
numBoxes = 0
function newText(){
numBoxes++
$('<div id="' + numBoxes + '"><input id="soft_text_' + numBoxes +
'" type="text"></div>').insertBefore($('button#new'))
}
function logHard(){
console.log($('input#hard_text').val())
}
function logSoft(){
$('div').each(function(){
console.log($('input#soft_text_' + this.id).val())
})
}
HTML:
<html><body>
<input id="hard_text" type="text" name="first_text">
<button id="new" onclick="newText()">Add new text box</button>
<button onclick="logHard()">Log first text box</button>
<button onclick="logSoft()">Log new text boxes</button>
</body></html>
テキストがない可能性があります。 – putvande
* "私は正確にそれを簡素化するために全力を尽くしました" *簡素化は良いですが、それは[mcve]でなければなりません。この場合、ブラウザベースの技術であるため、スタックスニペット( '<>'ツールバーボタン)を使用して**実行可能** MCVEにしてください。 –
これはあなたが必要とするものです[このリンクを確認してください](http://stackoverflow.com/questions/38322394/jquery-copy-dynamically-added-table-rowues-into-next-row/38328193#38328193 ) –