开发者

Getting call back to function within nested html tag

I have a callback, which I've had help on previously, which gets the last slide visible on a jCarousel.

The callback itself works, but its getting the list (which is the first tag), and I want it to get the alt attribute from the HTML. Is there anything I should be doing to delve deeper to grab the desired attribute?

I'm trying to get the alt attribute from the image tag and not the first list or anchor.

function itemVisibleIn(carousel) {
    $("#gallerydescription").html( $(this).attr("alt")); 
};

<li><a href="images/gallery/placeholder1.png" rel="shadowbox" title="This is the description">**<img class="caption开发者_如何学C" src="images/gallery/placeholder1.png" width="750" height="450" title="test Title1" alt="This is the title" />**</a></li>


If I'm understanding you correctly, you want to use find to get that img. Something like this:

$(this).find("img").attr("alt")

If needed, the selector passed to find can be more specific to distinguish between multiple images. Possibly something like this, to just get the image with a class of caption:

$(this).find("img.caption").attr("alt")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜