Crossbrowser Html5 Black and white jQuery plug in

Just one line of JS Code

1 add jQuery and plug in to the page

<script src="js/jquery.min.js"></script>
<script src="js/jQuery.BlackAndWhite.js"></script>

2 add this class to the wrapper of the image that you want make in Black and White

<div class="bwWrapper" >
	<img src="path/to/your/image" width="image width" height="image height" / >
</div>

3 set the wrapper in this way from the css:

.bwWrapper {
	position:relative;
	display:block;
}

4 initialize the plug in on window load (no $(document).ready()) :

$(window).load(function(){
	$('.bwWrapper').BlackAndWhite({
		hoverEffect : true, // default true
		// set the path to BnWWorker.js for a superfast implementation
		webworkerPath : false,
		// for the images with a fluid width and height 
		responsive:true,
		speed: { //this property could also be just speed: value for both fadeIn and fadeOut
	        fadeIn: 200, // 200ms for fadeIn animations
	        fadeOut: 800 // 800ms for fadeOut animations
	    }
	});
});

Demo

Features

Download on Github


© Gianluca Guarini 2012