Elvin
Elvin

Reputation: 367

Cant remove first TR with jquery

For some strange reason i am unable to remove the first <tr> with this code:

$('tbody tr#2 .is_KW').remove();

This is my html table code:

<tbody>
<tr id="2" class="is_KW">
    <td class="KW" style="border-left: 1px solid white;border-right: 1px solid #F4F4F4;padding: 12px 14px;position: relative;text-align: left;">
        <img src="img/world/af.png" alt="" title="af" style="vertical-align:middle;"> sweden
    </td>
    <td class="RR" style="border-left: 1px solid white;border-right: 1px solid #F4F4F4;padding: 12px 14px;position: relative;text-align: left;">
        <strong>
        1000+ </strong>
    </td>
</tr>
</tbody>

Any ideas?

Upvotes: 0

Views: 162

Answers (1)

Denys S&#233;guret
Denys S&#233;guret

Reputation: 382130

It should be

$('tbody tr#2.is_KW').remove();

Your selector, with the additional space, was targeting an element with class is_KW inside the tr element.

Note that when you have an ID, you should only use it :

$('#2').remove();

except of course if the class is meant as a condition for the removal and might be not present.

Upvotes: 5

Related Questions