返回到:Prototype – 元素对象
此方法设置元素的视觉不透明度,同时解决各种浏览器中的不一致问题。
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">Click the button to see the result.</p>
<input type = "button" value = "Click" onclick = "reduceOpacity();"/>
</body>
</html>返回到:Prototype – 元素对象
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9008.html
支付宝
微信