Try this, instead:

$(".trigger").click(function () {
    $(this).parents(".container").hide("slow");
});

That should get you what you're looking for.

--John

On Dec 9, 2007 7:53 PM, ebakunin <[EMAIL PROTECTED]> wrote:
>
> I am having trouble understanding how to use $(this) in a function. I
> would like to refer to a div container by an image in that container.
> The architecture is something like this:
>
> <div class="container">
>   <div class="subcontainer"><img class="trigger" src="" /></div>
> </div>
>
> Ideally I would use:
>
> $(".trigger").click(function () {
>      $(".container:has(this)").hide("slow");
> });
>
> But this doesn't work. I could use .parent().parent(), but that's bad
> practice. What is the correct way to approach this problem? Thanks.
>

Reply via email to