Home › Forums › CSS › Image Rollover and IE7 › Re: Image Rollover and IE7
June 24, 2012 at 5:59 pm
#104827
Participant
The css way was not working, so I did it via jquery, ha ha.
jQuery(function($) {
$(document).ready(function(){
// Preload all rollovers
$("#roller img").each(function() {
// Set the original src
rollsrc = $(this).attr("src");
rollON = rollsrc.replace(/.jpg$/ig,"_over.jpg");
$("").attr("src", rollON);
});
// Navigation rollovers
$("#roller a").mouseover(function(){
imgsrc = $(this).children("img").attr("src");
matches = imgsrc.match(/_over/);
// don't do the rollover if state is already ON
if (!matches) {
imgsrcON = imgsrc.replace(/.jpg$/ig,"_over.jpg"); // strip off extension
$(this).children("img").attr("src", imgsrcON);
}
});
$("#roller a").mouseout(function(){
$(this).children("img").attr("src", imgsrc);
});
});
});
Thanks,