On Mon, Dec 8, 2008 at 2:45 AM, janis.zalitis <[EMAIL PROTECTED]> wrote:

>
> Hey!
>
> I have a problem with find:
>
> It only appears to find "descendant" elements of a collection or
> element.
> I've been using JQuery for 3 years and unless memory fails me, find
> used to find stuff on the same level as well.
>
> I posted it as bug report here
> http://dev.jquery.com/ticket/3694
>
> And looking at the find example over at http://visualjquery.com/ it
> seems that it should select elements on the same level since the
> example basically selects spans using find and then selects those that
> have "t" letter in them, again, using find.


Here's the code I believe you're referring to:

var newText = $("p").text().split(" ").join("</span> <span>");
newText = "<span>" + newText + "</span>";

$("p").html(newText)
      .find("span")
        .hover(function () { $(this).addClass("hilite"); },
               function () { $(this).removeClass("hilite"); })
      .end()
      .find(":contains('t')")
        .css({"font-style":"italic", "font-weight":"bolder"});

The first .find() get spans that are descendants of the p at the beginning
of the chain. The .end() in the middle pops us back up to the 'p' so the
next .find() is again searching descendants of the 'p'.

- Richard

Reply via email to