tags:

views:

45

answers:

3

hi ,

how to find if there are no divs present inside the DIv droping_area in JQUery

like

  <div id="droping_area">

   <div id='a'></div>
   <div id='b'></div>
   <div id='c'></div>

  </div>
+4  A: 
var isempty = ($("#droping_area div").length == 0);
Ghommey
+2  A: 

If you want to check if there are no divs inside your container use $('#droping_area div').length property (it should be 0). If you want to make sure if there are no other elements as well use this as a selector:

$('#droping_area:empty')

This will give you the dropping area div only if it will be empty.

RaYell
Missing the div tag in your first bit of code :)
Russ Cam
Indeed, thanks for noticing that
RaYell
+2  A: 

Another way:

$("div", $("#droping_area")).size() == 0
Gumbo
This returns the same number as the 'length' property of the jQuery object. However, it is slightly slower, so length should be used instead.
Braveyard
@Aaron: But using the parent as context is faster.
Gumbo