低仿人民日报 由灰色逐步变彩色 (js+css实现)

参考网页变灰:https://blog.csdn.net/oopxiajun2011/article/details/105318044

人名日报图片点击后由灰色变回彩色:https://mp.weixin.qq.com/s/JSntpqo0zi7ZsEC0K-xKpA

我自己花了2分钟搞了一个类似于人民日报 这个效果。

<html>
<head>网页内容逐步变灰</head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<body>

<img style=" -webkit-filter: grayscale(100%);" src="17630702.jpg"></img>
<script>
var int;
var vue=100;
function  change(){
if(vue>0){

vue=vue-1;
$('img').attr("style","-webkit-filter: grayscale("+vue+"%);");
}
else{
clearInterval(int);
}
}

$('img').click(function(){

int=self.setInterval("change()",100);

  
 
})

</script>
</body>
</html>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章