Monday, February 22, 2010

Re: [jQuery] tooone7 Can't understand this... Want to make a image appear on active link

Jonathan Vanherpe (T & T NV) wrote:
>
> tooone777 wrote:
>> $("ul#nav_prim a")[i]...
>
> you need to use
>
> $("ul#nav_prim a").eq(i)...
> or
> $("ul#nav_prim a:eq("+i+")")...
>
> Jonathan
> --
> Jonathan Vanherpe - Tallieu & Tallieu nv - jonathan@tnt.be
>
>

I changed my code to the way you suggested, the error message is now gone
but the background image doesn't change.

However, if it looks like this:

function displayBgImg() {
for (var i=0; i<$("ul#nav_prim a").length; i++) {
if ($("ul#nav_prim a")[i] == document.URL) {
$("ul#nav_prim a").eq(i).css("background-image",
"url(images/nav_bg.gif)");
}
}
}

it works!

Notice that i only have "eq(i)" on line 4 but not on line 3.

Do you mind explaining what's happening when i use ".eq(i)" instead of
"[i]"?

Thank you very much for the help Jonathan :)

--
View this message in context: http://old.nabble.com/tooone7-Can%27t-understand-this...-Want-to-make-a-image-appear-on-active-link-tp27686495s27240p27686800.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate