Here you go:
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>bluantinoo CSS Grayscale Bg Image Sample</title> <style type="text/css"> div { border: 1px solid black; padding: 5px; margin: 5px; width: 600px; height: 600px; float: left; color: white; } .grayscale { background: url(yourimagehere.jpg); -moz-filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); -o-filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); -webkit-filter: grayscale(100%); filter: gray; filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); } .nongrayscale { background: url(yourimagehere.jpg); } </style> </head> <body> <div class="nongrayscale"> this is a non-grayscale of the bg image </div> <div class="grayscale"> this is a grayscale of the bg image </div> </body> </html>
Tested in FireFox, Chrome and IE. I also added an image to show the results of my implementation. 
EDIT: Also, if you want the image to simply switch back and forth using jQuery, here is the source of the page for this ... I have included the web link in jQuery and the image that is online so you can just copy / paste, to check this:
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>bluantinoo CSS Grayscale Bg Image Sample</title> <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <style type="text/css"> div { border: 1px solid black; padding: 5px; margin: 5px; width: 600px; height: 600px; float: left; color: white; } .grayscale { background: url(http://www.polyrootstattoo.com/images/Artists/Buda/40.jpg); -moz-filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); -o-filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); -webkit-filter: grayscale(100%); filter: gray; filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); } .nongrayscale { background: url(http://www.polyrootstattoo.com/images/Artists/Buda/40.jpg); } </style> <script type="text/javascript"> $(document).ready(function () { $("#image").mouseover(function () { $(".nongrayscale").removeClass().fadeTo(400,0.8).addClass("grayscale").fadeTo(400, 1); }); $("#image").mouseout(function () { $(".grayscale").removeClass().fadeTo(400, 0.8).addClass("nongrayscale").fadeTo(400, 1); }); }); </script> </head> <body> <div id="image" class="nongrayscale"> rollover this image to toggle grayscale </div> </body> </html>
EDIT 2 (for IE10-11 users): The solution above will not work with the changes Microsoft has made to the browser recently, so an updated solution has appeared here that will allow you to get grayscale (or discolor) your images.
<svg> <defs> <filter xmlns="http://www.w3.org/2000/svg" id="desaturate"> <feColorMatrix type="saturate" values="0" /> </filter> </defs> <image xlink:href="http://www.polyrootstattoo.com/images/Artists/Buda/40.jpg" width="600" height="600" filter="url(#desaturate)" /> </svg>
Element808 Feb 20 '14 at 5:33 2014-02-20 05:33
source share