Learn Prototype
Prototype Resources
Selected Reading
© 2011 TutorialsPoint.COM
|
Prototype setOpacity() Method
This method sets the visual opacity of an element while working around inconsistencies in various browsers.
The opacity argument should be a floating point number, where the value of 0 is fully transparent and 1 is fully opaque.
Element.setStyle method uses setOpacity internally to set opacity.
Syntax:
element.setOpacity(opacity);
|
Return Value:
Example:
<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>
|
To understand it in better way you can Try it yourself.
|
|
|