六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 192|回复: 0

用JQuery改变图片的透明度

[复制链接]

升级  17.33%

74

主题

74

主题

74

主题

举人

Rank: 3Rank: 3

积分
252
 楼主| 发表于 2013-1-29 13:44:57 | 显示全部楼层 |阅读模式
下面的例子展示了你如何改变项目的透明度。当鼠标滑过<img>标签时,用hover()函数设置透明度样式。
 
 
<!DOCTYPE html><html><head>    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>    <script text="text/javascript">        const OUT_OPACITY = 0.4;        const OVER_OPACITY = 1.0;        $(function() {            $("div#miniGallery img").css("opacity", OUT_OPACITY)                .hover(                    function () {                        $(this).animate({opacity:OVER_OPACITY});                    },                    function () {                        $(this).animate({opacity:OUT_OPACITY});                    }                );            });    </script></head><body>     <div id="miniGallery">        <img src="http://helpexamples.com/flash/images/image1.jpg" width="150" />        <img src="http://helpexamples.com/flash/images/image2.jpg" width="150" />        <img src="http://helpexamples.com/flash/images/image3.jpg" width="150" />    </div> </body></html> 
 
 
 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表