【发布时间】:2016-06-14 22:44:24
【问题描述】:
我有以下表格标题:
<table id="time" class="new_table" border="0" cellpadding="2">
<thead>
<tr>
<th scope="col" rowspan="2" class="sortHead">
<a href="#" id="unitSort">Unit</a>
</th>
<th colspan="2" id="startDateHead" class="sortHead">
<a href="#" id="startDateSort">Start</a>
</th>
<th colspan="2" id="endDateHead" class="sortHead">
<a href="#" id="endDateSort">End</a>
</th>
<th rowspan="2" class="sortHead">
<a href="#" id="distanceSort">Distance (miles)</a>
</th>
<th rowspan="2" class="sortHead">
<a href="#" id="locationSort">Location</a>
</th>
<th rowspan="2" class="sortHead">
<a href="#" id="driverName">Driver Name</a>
</th>
</tr>
当用户单击按钮时,我正在动态地将 img 标签添加和删除到 a 标签。我如何删除该表的 a 标签内的所有 img 标签?
我试过了:
$('#time th a').each(function() { $(this).remove('img'); });
添加到a标签的img元素示例如下:
<a href="#" id="driverName">Driver Name<img id="test" src="test.png" width="10"></a>
【问题讨论】:
标签: javascript jquery html