您可以将单击处理程序绑定到按钮,该按钮遍历DOM到其包含的内容<tr>,然后从那里找到文本框:
// Bind a click handler to all buttons in the table...
$('table :button').click(function () {
var text = $(this) // "this" is the button which was clicked
.closest('tr') // find the <tr> which contains it...
.find(':text') // find the text box within that <tr>...
.val(); // and get its value
alert(text);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5066 次 |
| 最近记录: |