Take the 2-minute tour ×

I have the following markup:

<div id="parent">
    <div id="divToRemove">

And I have the following jQuery to remove the first div which works fine:


Is this the best way to remove the first component? Or is it more efficient to use selectors? An example would be great!

Please note, I know I can use:


however I'd like to be able to use selectors in this instance (reasons outside of scope of question).

Thanks, Norm.

share|improve this question

6 Answers 6

up vote 6 down vote accepted

This should be the fastest and safest:

share|improve this answer

You want


or it will remove all <div> within the parent <div>.

share|improve this answer

you can try this. It work perfectly on me


share|improve this answer

use this if you're only talking about removing immediate children div of parent. and it will be better than .find() when you have more inner divs.

share|improve this answer

let's say. you are doing JS event and you have access to "this" I will do it this way.


clarify, this is not the most efficient way but useful in interactive event. alternatively, you can make use of a few selector :

//closest,parent,next,prev,find,children and nth-child()
share|improve this answer

Ive got another one:

$('#parent > div:first').remove();

The '>' selects children of the element referenced to the left, and of course ':first" refers to the first child.

share|improve this answer

Your Answer


