jquery: remove first two children?

i have three td's inside of #mainmenu.

<table cellpadding="0" cellspacing="5" id="mainmenu">
    <tbody>
        <tr>
            <td valign="top" class="menu_sub">
                something
            </td>
            <td valign="top" class="menu_sub">
                something
            </td>
            <td valign="top" class="menu_sub">
                something
            </td>
        </tr>
    </tbody>
</table>

I want to remove the first two td's inside of my table, how can i do that?

$('#mainmenu td').remove();

Answers


Use the less than selector. Here is a jsfiddle

$('#mainmenu td:lt(2)').remove();

http://api.jquery.com/first-selector/

 $('#mainmenu td:first').remove();
 $('#mainmenu td:first').remove();

Need Your Help

Android - save/restore fragment state

android android-fragments fragment onresume back-stack

I have an Activity in which I go through several fragments. In every fragment I have several views (EditText, ListView, Map, etc).