jQuery的:替换表列内的跨度的内容 [英] Jquery : Replace the content of span inside the table column
本文介绍了jQuery的:替换表列内的跨度的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<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>
表可以有多个相同类型的行.
table can have multiple row of same type.
$(".update-link").click(function () {
var elem = $(this).closest('tr');
});
经过一些操作后,我想选择此垂直tr
的third td (class name ="type-column")
,并想用我自己的值替换first span (class name ="company-type")
的内容(例如,Hello World)
after some manipulation , i want to select the third td (class name ="type-column")
of this perticular tr
and want to replace the content of first span (class name ="company-type")
with my own value lets say (eg, Hello World)
我尝试过
elem.find("td:eq(2)").text("Hello World");
,但不起作用.救救我!
but its not working. help me!!
已更新 jsfiddle此处
推荐答案
您从未搜索过span
:
elem.find("td:eq(2)").find("span.company-type").text("Hello World");
这篇关于jQuery的:替换表列内的跨度的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文