.find() only searches down the tree (so child elements of .btn). You may
need some combination of .parents() or .siblings().

Cheers,
-Jonathan


On 11/5/07, nemozob <[EMAIL PROTECTED]> wrote:
>
>
> Hi, I'm trying to target the closets instance of an element with a
> class name target but I'm having trouble figuring out how to do this.
>
> So given this HTML
>
> <p class="target">how are you?</p>
> <p>hello</p>
> <p class="target">how are you?</p> <-- want to target this paragraph
> <p>I am fine</p>
> <div>
>        <div class="btn">button</div>
> </div>
>
> I'm trying to use something like the following to find the closest
> previous "target" element to "btn".
>
> $(".btn").click(function(){
>        $(this).find(".target:first").css('color','red');
> });
>
> Any ideas?
>
>

Reply via email to