![](/img/trans.png)
[英]How to assign value to dynamically created input box using javascript/Jquery
[英]How to get the dynamically created text box value in jsp using jquery javascript
我正在使用Javascript中的代碼,如下所示:
newTextBoxDiv.html('<td border="2">'+number+'</td>'
+'<td>'+grouptext+'</td>'
+'<td style="display:none">'+groupVal+'</td>'+'<td>'+itemText+'</td>'
+'<td style="display:none">'+itemId+'</td>'+'<td>'
+cuttingText+'</td>'+'<td style="display:none">'
+cuttingId+'</td>'+'<td><input type="text"
class="ui-state-default ui-corner-all" size="6" name="textbox'
+ counter +'" id="textbox' + counter + '" value="" size="13" ></td>'
+'<td><input type="checkbox" name="samples"/></td>'
+'<td><input type="text" class="ui-state-default
ui-corner-all" size="8" name="textbox' + counter
+'" id="textbox1' + counter + '" value="" size="13" >');
newTextBoxDiv.appendTo("#example");
我的問題是,當我單擊每一行時,我需要獲取一個文本框值。
您可以在表行上捕獲click事件,然后使用find
在表行的后代中查找文本框:
$("tr").click(function() {
var value = $(this).find("input[type='text']").val();
});
編輯
根據您的評論,如果它是一個復選框,並且您大概想查看是否已選中:
$("tr").click(function() {
var isChecked = $(this).find("input[type='checked']").is(":checked");
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.