<table id="addressbook" >
<thead>
<tr>
<th>Company</th>
<th>Documentation Address</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr id="table-row_1">
<td>Gigi World</td>
<td>Cresent Road
</td>
<td class="type-column"><span class="company-type">Shipper</span><br>
<span class="update-link"> <a data-code="11301181" id="Shipper" data-toggle="modal" role="button" class="rate update-anchor" href="#update-addresstype">Update</a>
</span> <span id="delete-link" class="pull-right delete-link"> <a href="#" class="view-all">Delete</a></span>
</td>
</tr>
</tbody>
</table>
表可以有多个相同类型的行。
$(".update-link").click(function () {
var elem = $(this).closest('tr');
});
经过一些操作后,我想选择此third td (class name ="type-column")
的{{1}},并希望用我自己的值替换tr
的内容(例如,Hello World)< / p>
我试过
first span (class name ="company-type")
但它不起作用。帮助我!!
编辑: 已更新jsfiddle here
答案 0 :(得分:2)
您从未搜索过span
:
elem.find("td:eq(2)").find("span.company-type").text("Hello World");
答案 1 :(得分:0)
您的代码中有一些拼写错误。请查看此更新:http://jsfiddle.net/V85Vx/29/
$(".update-link").click(function () {
alert("update clicked")
var elem = $(this).closest('tr');
elem.find("td:eq(1)").text("Hello World");
});