I have a series of divs with the class "addedelement" which are dynamically added. Inside all of this layers there are more nested divs, one of them containing some images with attached events. When I click on one of this images I want to know if it is inside the LAST of those divs:
if($(this).is('div.addedelement:last div.contextmenu img.up'))
{
alert('Ok');
}
I don't know why, but this conditional expression is fired independently of the case in which the trigger is inside the last 'elementadded' div or not. But if I try to apply a css to the element like this:
$('div.addedelement:last div.contextmenu img.up').css('display','none');
It works like a charm. What I'm missing? Can anybody help me?