用JQuery改变图片的透明度
下面的例子展示了你如何改变项目的透明度。当鼠标滑过<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>
页:
[1]