I add the "lady" inside an id of a certain box (this is done in a separate function)
$("#" + ladyid + "").appendTo("#" + boxid + "");
Well, what I want to know in the other function (the one below), is to know to which id (of the boxes) the queen has gone
setInterval(function() {
var lady1 = ;
var lady2 = ;
var lady3 = ;
var lady4 = ;
var lady5 = ;
var lady6 = ;
var lady7 = ;
var lady8 = ;
});
What I want is for the program to know all the time in which div each element is located, and add this information to a variable
You can do this using the property
parent()
to know which is the parent div in which the queen is located and then use it.attr('id')
to get its id. I leave you an example so that you can see it more clearly:In your case if you are in a different function you should use
$("#dama").parent().attr('id');