我使用jquery創建文本框。之後我想從文本框中獲取數據並在我的表格中插入答案。這是我創建文本框的代碼。從jquery創建的動態文本框中檢索數據
$(document).ready(function() {
var counter = 2;
$("#addButton").click(function() {
if (counter > 10) {
alert("Only 10 textboxes allow");
return false;
}
var newTextBoxDiv = $(document.createElement('div'))
.attr("id", 'TextBoxDiv' + counter);
newTextBoxDiv.html('<label>Raspuns' + counter + ' : </label>' +
'<input type="text" name="textbox' + counter +
'" id="textbox' + counter + '" value="" >');
newTextBoxDiv.appendTo("#TextBoxesGroup");
counter++;
});
$("#removeButton").click(function() {
if (counter == 1) {
alert("No more textbox to remove");
return false;
}
counter--;
$("#TextBoxDiv" + counter).remove();
});
});
如何從文本框中選擇數據?我使用C#,這是一個asp.net應用程序
重要的一個小小的建議:使用CSS類在你的元素,後來選擇他們更easyly – chepe263 2012-04-02 13:46:25