![](/img/trans.png)
[英]On click adding the text from a button to a Input box with jQuery or JS
[英]<JSP/JQuery> How to make text input box when click on the button
我有一个表(包括复选框),数据如下。 还有“ADD”按钮。
<script type="text/javascript">
I don't know what comes here..
</script>
.
.
.
.
<colgroup>
<col style="width:30px;"/>
<col style="width:200px;"/>
<col style="width:300px;"/>
<col style="width:px;"/>
</colgroup>
<thead>
<tr>
<th scope="col"><input type="checkbox" id="chkAllGrp" name="chkAllGrp" onclick="CommonUtil.chkAll('chkAllGrp','chkGrp')"/></th>
<th scope="col">LINE</th>
<th scope="col">ITEM</th>
</tr>
</thead>
<tbody>
<c:forEach items="${resultList.content}" var="result" varStatus="status">
<tr>
<td><input type="checkbox" id="chkGrp" name="chkGrp" value="${result.line}"/></td>
<td style="cursor:pointer;" onclick="fnSelGrp('${result.line}', '${result.item}')">${result.line}</td>
<td>${result.item}</td>
</tr>
</c:forEach>
<div class="area_btnA clfix mgB20">
<a href="#" onclick="addInputBox();return false;" class="btnA"><strong>ADD</strong></a>
</div>
我想要做的是,当我点击ADD按钮时,显示数据行底部会出现一行新的文本输入框。 有人可以帮助我使用OnClick事件代码吗?
就像是 ,
function addInputBox(){
jQuery('#myTable tr:last').after('<tr><input type="checkbox" name="chkGrp" value=""/></tr><tr>your html content here</tr>');
}
#myTable
是表id。
尝试这样的事情
function addInputBox(){
var tr = '<tr>';
tr += '<td><input type="text" id="mytextbox" name="mytextbox" value=""/></td>'
tr += '<td></td><td></td>'
tr += '</tr>'
jQuery('#table_id').append(jQuery(tr));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.