ahschmidt Posted May 20, 2011 Share Posted May 20, 2011 What I am trying to do is to create an effect where a element (called 'box') is rolled over, and an image appears. When you roll over it a second time another image appears, and so forth.The image urls are pulled from an array which will loop once the end of the array is reached.What I would like to do, and am not sure is working is the the previous image should be deleted so I don't have a crazy stack of images. I think that I am running into problems by the way that I am adding classes to the images to choose the right one to be deleted. $(document).ready(function(){ var i = 0; $(".box").mouseover( function(){ $(".imgHolder").append('<img class="thisImg '+('img'+i)+'" src="images/'+imgArray[i]+'" />'); $('img').remove('img'+(i-1)); //<-- This is the delete line that I don't think is working correctly. // - ignore this line for the time being... it is here to make the images stack in the Z axis. $(".thisImg").css({position:"absolute",top:50,left:0}); if(i==(imgArray.length-1)){ i=0; }else{ i++; } });}); Thanks for any help you can provide! Link to comment Share on other sites More sharing options...
ahschmidt Posted May 20, 2011 Author Share Posted May 20, 2011 OK, you have to love it when it is something stupid... $('img').remove('img'+(i-1)); should be... $('img').remove('.img'+(i-1)); The '.' before the class name was left out. Cool. Link to comment Share on other sites More sharing options...
thescientist Posted May 20, 2011 Share Posted May 20, 2011 If you're stacking, why are you deleting the images? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.