How to get the child of an element being dragged with jQuery UI

Posted by Walden on Stack Overflow See other posts from Stack Overflow or by Walden
Published on 2010-06-07T00:48:16Z Indexed on 2010/06/07 0:52 UTC
Read the original article Hit count: 413

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.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-ui