我使用jQuery tmpl插件将行附加到表中。 每行对应三个输入字段和一个“保存”链接。 保存我正在使用的链接:
$(".saveClick").live('click',function(){
// 1. get 3 values for the row in question (stuck here)
// 2. process values via ajax (no problems here)
// 3. create new row from template (no problems here)
});
我可以使用AJAX来处理值,我只是不知道访问这些值的最佳方法是什么?
任何建议都会膨胀。
由于
编辑:
澄清HTML:
<table id=inputTable>
<tr>
<td>cola</td>
<td>colb</td>
<td>colc</td>
<td> </td>
</tr>
</table>
jQuery模板:
<script id="tmplAddRow" type="text/x-jquery-tmpl">
<tr>
<td><input id="inA"></td>
<td><input id="inB"></td>
<td><input id="inC"></td>
</tr>
</script>
答案 0 :(得分:0)
所以看起来您的问题确实是:“我如何访问表格单元格值?”
之前曾问过,所以你可以在How to get a table cell value using jQuery?找到答案。
答案 1 :(得分:0)
如果您使用表格,您可以“返回”直至保存链接行的相对位置以及找到字段后
$(".saveClick").parent().find("selector-of-field");
答案 2 :(得分:0)
示例:
$(".saveClick").live('click',function(){
alert($(this).closes("tr").find("td:nth-child(1) input").val());
}