jQuery 黑白插件

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,
        // this option works only on the modern browsers ( on IE lower than 9 it remains always 1)
        intensity:1,
        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
        }
    });
});
原文地址:https://www.cnblogs.com/jweb/p/4611171.html