[英]Jquery : Replace the content of span inside the table column
<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');
});
在一些操作之后,我想選擇這個特定tr
的third td (class name ="type-column")
並想要用我自己的值替換first span (class name ="company-type")
的內容first span (class name ="company-type")
讓我們說(例如,Hello World)
我試過了
elem.find("td:eq(2)").text("Hello World");
但它不起作用。 幫我!!
你從來沒有搜索過span
:
elem.find("td:eq(2)").find("span.company-type").text("Hello World");
您的代碼中有一些拼寫錯誤。 查看此更新: 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");
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.