script.aculo.us - Fade 淡入淡出效果
说明
通过将 CSS 显示属性设置为 none,可使元素淡入淡出并在效果结束时将其从文档流中移除。与 Effect.Appear 相反。
语法
您可以使用以下两种形式之一来使用此效果 −
new Effect.Fade('id_of_element', [options]); 或 new Effect.Fade(element, [options]);
效果特定参数
此效果除了通用参数外,没有任何其他参数。
示例
<html> <head> <title>script.aculo.us examples</title> <script type = "text/javascript" src = "/javascript/prototype.js"></script> <script type = "text/javascript" src = "/javascript/scriptaculous.js?load = effects" ></script> <script type = "text/javascript"> function FadeEffect(element){ new Effect.Fade(element, { duration:1}); } function ShowEffect(element){ new Effect.Appear(element, {duration:1, from:1.0, to:1.0}); } </script> </head> <body> <div onclick = "FadeEffect('hideshow')"> Click me to fade out the image </div> <br /> <div onclick = "ShowEffect('hideshow')"> Click me to display the image once again </div> <br /> <div id = "hideshow"> <img src = "/images/scriptaculous.gif" alt = "script.aculo.us" /> </div> </body> </html>
这将产生以下结果 −