I’ve the following code:
$( init );
function init() {
$(".Arrastrable").draggable({
stop: function(event, ui) {
var pos = $(this).position();
$("div#stop").text("Pos: "+ pos.left + ", " + pos.top);
}
});
}
In the HTML I’ve the following:
<body>
<div id="contenido" style="height: 400px;">
<form name="Registro" action="Guardar" method="post" id="Registro">
<table
<tr>
<td>
<div class="Arrastrable">
<img src="./css/Imagenes/mesa.png" id="mesa1"></img>
</div>
<div class="Arrastrable">
<img src="./css/Imagenes/mesa.png" id="mesa2"></img>
</div>
</td>
</tr>
</table>
</form>
</body>
I need to get the ID value of the actual draggable element,I’ve tried using $(ui.item).attr("id") but it didn’t work. I don’t know if I have to add another method or what.
I don’t remember exactly how the property is called, I’ll look it up in jsfiddle and edit here, but you could do this:
and check the properties in Google web developer tools or firebug.
OK, checking here, you can see in the console the properties of the event and the ui object, and the property you’re looking for in
event.target.firstChild.id(or use jQuery)