- Prototype Tutorial
- Prototype - Home
- Prototype - Short Overview
- Prototype - Useful Features
- Prototype - Utility Methods
- Prototype - Element Object
- Prototype - Number Processing
- Prototype - Strings Processing
- Prototype - Array Processing
- Prototype - Hash processing
- Prototype - Basic Object
- Prototype - Templating
- Prototype - Enumerating
- Prototype - Event Handling
- Prototype - Form Management
- Prototype - JSON Support
- Prototype - AJAX Support
- Prototype - Expressing Ranges
- Prototype - Periodical Execution
- Prototype Useful Resources
- Prototype - Quick Guide
- Prototype - Useful Resources
- Prototype - Discussion
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
Returns an HTML element.
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>
Output
prototype_element_object.htm
Advertisements