jqueryを使用してボタンのクリックイベントに動的テキストボックスIDを作成したい。私は、ボタンをクリックすると3つのテキストボックスを作成する関数を作成しました。私が必要とするのは、すべてのテキストボックスに固有のIDが必要です。ここで動的テキストボックスIDを作成する
は、関数である: -
function CreateTextBox(value) {
return '<div class="col-md-12"><div class="col-md-3"><label>Ingredients</label><input class="form-control"name = "text1" id="ring" type="text" value = "' + value + '" /> </div>'+
'<div class="col-md-3"><label>Quantity</label><input class="form-control"name = "text2" type="text" id="rqty" value = "' + value + '" /> </div>'+
'<div class="col-md-3"><label>Measure Unit</label><input class="form-control"name = "text3" id="runit" type="text" value = "' + value + '" /> </div>'+
'<div class="col-md-3"><input type="button" value="Remove" class="btn btn-info remove" id="rm"/></div></div>'
}
このコードは、最初に私のために正常に動作します。この関数を2回目に実行すると、別のID(ring1、rqty1、runit1など)が必要になります。