hi to every one i am new in jquery. i want to make an app using the drag and drop events in jquery.but i am NOT able to select a div among a set of divs with thesame name contained in a main div.please can anybody help me ? note these set of divs are generated dynamically ,getting the data from the database
views:
54answers:
2how to select a div among sets of divs with thesame class name and contained in a main container div
To select a specific div, give it an ID.
<div class="container">
<div>content</div>
<div id="target">content</div>
</div>
$('#target') will let you get that specific div.
If you need to get a particular element in a list you can use the eq() function.
$('.container').eq(1)
will get the #target div
It is just really tough to tell exactly what you need.
I sounds like you have elements that are generated dynamically in your javascript, and you are having trouble making those draggable.
I assume this means that you have successfully made other elements on the page draggable that were not added dynamically.
IF this is the case, before you add your new element to the page, just do the same draggable() call on it before you add it.
// Create new element
var $newElement = $("<div class='suggestion'>I'm a suggestion</div>");
// Make it draggable
$newElement.draggable();
// Append it to your container
$newElement.appendTo('.suggestions');
If this is not what you mean, then please be very clear and detailed in your question. Please also add a code example, which often explains much. :o)