drag and drop question
I have a list of items, witch i use with the drag and drop effect of jquery ui, to drop in a textarea, this list of items have this form in the html
<li fieldID="field-1">Some text</li>
I know that i can get开发者_如何学Python in the event drop, the text associate to the li
but my question is how can i get the html, or the attribute called field-id
in the event droppable
. I tried using this ui.draggable.html()
but doesn't give me the html only the text.
Also any suggestions to improve my code are also welcome. Thanks.
Here's an example of my code
Code
You want to use the attr()
function to retrieve the value of an attribute from a jQuery object. Since ui.draggable is a jQuery object wrapping the element being dragged, ui.draggable.attr('fieldID')
will give you "field-1" for the html you posted.
See: http://jsfiddle.net/Q6use/3/
like Bryan Ross said: http://jsfiddle.net/Q6use/3/
精彩评论