I need jQuery to echo out some data on a draggable image. I’m able to call up the location of the image relative to the window. I added event.target.nodename to the text that echos out but it only returns the html tag the image is in. This is all well and good, but because I’m using a while loop to produce several images I can’t tell which event.target.nodename is referencing which image. Here is a sample of the jQuery code.
$(document).ready(function(){
$(function()
{
$(".ui-widget-content").draggable(
{
stop: function(event,ui)
{
var Stoppos = $(this).position();
$(".location").text("STOP: \nLeft: "+ Stoppos.left + "\nTop: " + Stoppos.top +
event.target.nodeName);
}
}
);
$(".droppable").droppable();
});
});
Note: Each image the while loop produces a unique class so there isn’t a problem when it comes to identifying each image based on the class.
$(event.target).class()instead ofevent.target.nodeNameshould get you the class of the image