Prototype - setOpacity() 方法
此方法设置元素的视觉不透明度,同时解决不同浏览器之间的不一致问题。
opacity 参数应为浮点数,其中 0 表示完全透明,1 表示完全不透明。
Element.setStyle 方法在内部使用 setOpacity 来设置不透明度。
语法
element.setOpacity(opacity);
返回值
返回 HTML 元素。
示例
<html> <head> <title>Prototype examples</title> <script type = "text/javascript" src = "/javascript/prototype.js"></script> <script> function reduceOpacity() { $('test').setOpacity( 0.5 ); // This is equivalent to // Element.setStyle({ opacity: 0.5 }); } </script> </head> <body"> <p id = "test">单击按钮查看结果。</p> <input type = "button" value = "Click" onclick = "reduceOpacity();"/> </body> </html>