Question : How can I determine if div inside another div using jquery or javascript?

I have several divs that are not nested but each have a position, top and left value. I need to determine if any divs exist inside another div based on these (the position) values.

If there is another way to do it, I would be impressed but these items have been dropped onto the screen by jquery draggable/droppable.

Many many thanks!

Answer : How can I determine if div inside another div using jquery or javascript?

I got it...this is really tricky lol

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
// Make the drop_area div droppable
			$("#drop_area").droppable({
				accept: "#temp_item",
				drop: function(event,ui){

					// Get the id of the item that was just dropped
					var id = ui.draggable.attr('id');

					// Clone the item and append it to the drop area
					$(this).append($(ui.draggable).clone());

					// Remove the ability to drag the current item around
					$('#temp_region').removeClass("dragg");
					$('#temp_region').removeClass("ui-draggable");

					// Create a new name for the dropped item
					var $new_name = rnd();
					$('#' + id).attr('id', $new_name);

					// Remove the dropped item's CSS position directives
					$('#' + $new_name).css('top', '');
					$('#' + $new_name).css('left', '');

					// Make the newly renamed item droppable so that nesting can take place
					$('#' + $new_name).droppable({
						accept: '*',
						drop: function(e,ui){
							if ( e.clientY < $(this).closest("div").position().top + $(this).closest("div").height() )
							{
								// Determine what is being dropped and onto what
								var dropped_item = $(ui.draggable).attr('id');
								var dropped_on = $(this).attr('id');

								// Get the HTML of each item
								var dropped_html = $('#' + dropped_item).html();
								var dropped_on_html = $('#' + dropped_on).html();

								// Remove the dropped item from the DOM
								$('#' + dropped_item).remove();

								// Append the dropped item into the item it was just dropped on
								$('#' + dropped_on).append(ui.draggable);

								// Remove the dropped item's CSS position directives
								$('#' + dropped_item).css('top', '');
								$('#' + dropped_item).css('left', '');

								// Let the user move the dropped item
								$('#' + dropped_item).draggable();
							}
						}
					});

					// Force the dropped item to only move around in the container
					$('#' + $new_name).draggable({containment: '#drop_area'});

					// All the user to snap items to each other for usability sake
					$('#' + $new_name).draggable({
						snap: true,
						stop: function(event, ui){
						}
					});
				}
			});
Random Solutions  
 
programming4us programming4us