<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>
表可以有多行相同的類型。jquery:替換表列內的span的內容
$(".update-link").click(function() {
var elem = $(this).closest('tr');
});
一些操作後,我要選擇此perticular tr
的third td (class name ="type-column")
,並希望與我自己的價值,以取代first span (class name ="company-type")
的內容可以說(例如,世界您好)
我試圖
elem.find("td:eq(2)").text("Hello World");
但它不工作。幫我!!
編輯: 更新jsfiddle here
是在'情商缺失的圓括號(2'只是一個錯字在你的代碼示例或它實際上是在你的產品代碼 – matewka