script.aculo.us - 漸隱效果


說明

它使一個元素淡出,並透過將 CSS 顯示屬性設定為無來在效果結束時將其從文件流中移出。與Effect.Disappear 相反。

語法

你可以使用以下兩種形式之一來使用此效果 −

new Effect.Fade('id_of_element', [options]);
OR
new Effect.Fade(element, [options]);

Effect 特定引數

此效果除了 通用引數 外,沒有任何其他引數。

示例

<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>

將產生以下結果 −

scriptaculous_effects.htm
廣告