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 )
attributeName
The name of the attribute to set.
value
A value to set for the attribute.
精彩评论