New Media Fun

Having fun in an online world

Archive for March, 2010

Updated jQuery Cheat Sheet

Posted by admin under Education, HTML

Impulse Studios have an updated Cheat Sheet for jQuery 1.4.

Here is the PDF

Or a handy HTML version at Future Colors.

Better Swap Image with jQuery

Posted by admin under HTML

Today, I needed to create a swap image for a left hand navigation. I am already using jQuery and I didn’t want to use Dreamweaver’s clunky image swap code. After some searching I found a great and simple snippet of code that will allow me to swap images all the images in the navigation with only 4 lines of code while using jQuery.

$(".img-swap").hover(
 function(){this.src = this.src.replace("_off","_on");},
 function(){this.src = this.src.replace("_on","_off");
});

Be sure to have a naming convention with your images. Images for off states will be xxxxxx_off.jpg and the hover state xxxxxx_on.jpg. Also add the class “img-swap” to the images.

Big thanks to Design Chemical, click on the link to see their example.