开发者

jquery img and desc swap

I'm trying 开发者_如何学JAVAto swap an img src and a text description with jquery. This is what i have so far but now working of course :)

$(document).ready(function(){
    $("#slideShow a").click(function() {
        var imgTitle = $(this).children('img').attr('title'); // Find the image title
        $("#thecap").html(' ' + imgTitle + ' ');
        $("#lgImage").attr('src', $(this).children('img').attr('rel'));
    });
});


You can't use the get .attr('src') and try to set a value to it. The last line should be:

$("#lgImage").attr('src', $(this).children('img').attr('rel'));

See: http://api.jquery.com/attr/

.attr( attributeName, value )

attributeNameThe name of the attribute to set.

value A value to set for the attribute.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜