[jQuery] Re: Simple JQuery selection question

2009-03-13 Thread James
No, when you use $(this), it is referencing the that was clicked on. In your code has no siblings. Now if you did this: test then $(this) does have a sibling. The is a sibling. That's why you have to use: $(this).parent(), which references the 's parent, , and then with that find

[jQuery] Re: Simple JQuery selection question

2009-03-13 Thread truthseekr
James, Thank you. It works perfectly. I am not sure why, but the following statement does not seem to find the title. $(this).attr("title", $(this).siblings("li.title").text()); Isn't it the same as $(this).parents().next('li.title').text() Any ideas? On Mar 12, 6:56 pm, James wrote: > One

[jQuery] Re: Simple JQuery selection question

2009-03-12 Thread James
One slight change to setting the image title by using $(this): $("img").click(function () { var $title = $(this).parent().next('li.title'); $title.css("text-decoration", "underline"); $(this).attr("title", $title.text());

[jQuery] Re: Simple JQuery selection question

2009-03-12 Thread James
Maybe something like: $("img").click(function () { var $title = $(this).parent().next('li.title'); $title.css("text-decoration", "underline"); $("img").attr("title", $title.text()); }); I haven't tested i