Return to Snippet

Revision: 8034
at August 28, 2008 12:05 by bcalloway


Initial Code
$(document).ready(function() {
		// Preload all rollovers
		$("#tabs img").each(function() {
			// Set the original src
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.jpg$/ig,"2.jpg");
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers
		$("#tabs a").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/2/);
			
			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.jpg$/ig,"2.jpg"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		$("#tabs a").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});
});

Initial URL

                                

Initial Description
jQuery script for navigation image rollovers

Initial Title
jQuery rollovers

Initial Tags
javascript, jquery

Initial Language
JavaScript