Doesn't that code give a "not a function" JavaScript error when you try to run it? Load the page with Firebug and it should log an error on this code when you click:
$(this).parent().parent().$(".dialog").dialog("open"); Let's break it down: $(this) - the "add" SPAN $(this).parent() - the H3 $(this).parent().parent() - the LI $(this).parent().parent().$ - undefined (a jQuery object does not have a $ property/method). $(this).parent().parent().$(".dialog") - error calling undefined function I think what you're looking for may be: $(this).parent().parent().find(".dialog").dialog("open"); -Mike > I have a list like: > <li> > <h3><span class="add">ADD</span></h3> > <div class="dialog">Content 1</div> > </li> > <li> > <h3><span class="add">ADD</span></h3> > <div class="dialog">Text 2</div> > </li> > > I want to open a dialog, which are the divs, when the ADD is clicked. > But I only want the dialog that is in the same li tag as the > Add button being clicked. I though the following might work, > but it's not > right: > > $(".add").click(function () { > $(this).parent().parent().$(".dialog").dialog("open"); > }); > > Shouldn't that go span -> h3 -> li -> div (dialog) ??? What > should it be?