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();
To remove elements and content, there are mainly two jQuery methods: remove() - Removes the selected element (and its child elements) empty() - Removes the child elements from the selected element.
remove() method takes elements out of the DOM. Use . remove() when you want to remove the element itself, as well as everything inside it. In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed.
usually <ul> tag contains only <li> tags. If you want to remove all <li> tags then $("#ulelementID"). html(""); will work.
RemoveAttr('id','none');
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With