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
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
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());
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
4 matches
Mail list logo