How to get the child of an element being dragged with jQuery UI
- by Walden
I have the following html:
<div id="gallery">
<ul>
<li>
<a href="url I want to get">link</a>
</li>
</ul>
</div>
and some jQuery that allows it to be dropped on another div:
$trash.droppable({
accept: '#gallery > li',
activeClass: 'ui-state-highlight',
drop: function(ev, ui) {
deleteImage(ui.draggable);
var $flickrparenturl = $("a").attr("href"); //only gets href of <li> #1, not <li> being dragged
$.post("updateDB.php", { 'flickrparenturl': $flickrparenturl } );
}
});
What is the correct way to get the href attribute of the child of the element being dragged? $("a").attr("href"); is only getting the href of the 1st li on the page, not the one being dragged.