In general, your code should look like this:
$('.image').each(function() { var panel = $(this).siblings('.descPanel'); $(this).mouseover(function() { panel.dialog('open'); }); }); $(".descPanel").dialog({ autoOpen: false, open: function() { $(this).siblings(".ui-dialog-titlebar").addClass("ui-state-error"); } });
You can check it out here .
Why? Well, when you call .dialog() , it wraps this <div> in a different set of elements, but more importantly, it moves these elements to the end of <body> , so they are no more. In the above example, we find panels that come with images and keep a link to them until they are moved.
As an aside, you should remove this id="tr" from your code, duplicate identifiers are just a problem! (and invalid HTML), use the class in these situations.
source share