开发者

Address html img tag in a tag jquery

I do have the following problem. I have the following code.

<a id='image1'> <img> &l开发者_如何学Ct;/img> </a>

Now how do i address the image inside those a tags.

You surely want to know why. Well, i have a slideshow, and it has an .active. class, i need But the problem is, the .active class is added to the <a> and not to the <img>. And since i need to change the src of the image, that is quite a problem.

So how do i address the image, when i only have the id of the a, i would really like doing this with JQUERY.

Thanks.


Try this :

$("#image1").find("img").attr("src","yourImageUrl");


This should return the image -

$("a#image1 > img")

Then you could change the src via -

$("a#image1 > img").attr("src","yourimage.gif")


you can do it like this:

$(".active img").mySuperAweSomeFunction();

You target the image in the active class.

to target the image in the link with the ID:

$("#img1 img").mySuperAweSomeFunction();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜