从所有锚标记内删除图像标记

mam*_*esh 2 html javascript jquery

我有以下表格标题:

<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>
Run Code Online (Sandbox Code Playgroud)

我在用户点击按钮时动态添加和删除img标签.当它们在那里时,如何删除该表的a标签中的所有img标签?

我试过了:

$('#time th a').each(function() { $(this).remove('img'); });
Run Code Online (Sandbox Code Playgroud)

添加到标记的img元素的示例如下:

<a href="#" id="driverName">Driver Name<img id="test" src="test.png" width="10"></a>
Run Code Online (Sandbox Code Playgroud)

gur*_*372 5

如何在该表的a标签中删除所有img标签.

只是

$('#time th a img').remove();
Run Code Online (Sandbox Code Playgroud)

演示