PHP & JavaScript Room :: 設置サンプル

実行結果

エフェクト操作:フェーディング:FadeTo()の使用例 | jQuery

▼ボタンをクリックすると、指定した透明度まで要素をフェードします。

くまさんケーキ

設置サンプルのソース

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <meta http-equiv="Content-Language" content="ja" />
      <meta http-equiv="Content-Script-Type" content="text/javascript" />
      <meta http-equiv="Content-Style-Type" content="text/css" />
      <meta http-equiv="imagetoolbar" content="no" />
      <title>エフェクト操作:フェーディング:FadeTo()の使用例 | jQuery</title>
      <link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
      <script type="text/javascript">
         $(function(){
            $("#btn_fadeto_0").click(function(){
               $("#sample img").fadeTo("slow",0);
            });
            $("#btn_fadeto_033").click(function(){
               $("#sample img").fadeTo("slow",0.33);
            });
            $("#btn_fadeto_05").click(function(){
               $("#sample img").fadeTo("slow",0.5);
            });
            $("#btn_fadeto_1").click(function(){
               $("#sample img").fadeTo("slow", 1);
            });
         });
      </script>
      <style type="text/css">
         #content { width:400px; text-align:center; }
         #sample { margin:10px auto; width:320px; height:240px; background-color:#E5D19E; }
      </style>
   <link rel="stylesheet" type="text/css" href="/common/css/example.css"></head>
   <body id='example3' class='example'><div class="ads" style="margin:32px auto;text-align:center;"></div><h1 class='h'><a href='/'>PHP &amp; JavaScript Room</a> :: 設置サンプル</h1>
<h3 class='h'>実行結果</h3>
      <div id="wrap">
         <h1>エフェクト操作:フェーディング:FadeTo()の使用例 | jQuery</h1>
<!-- CODE -->
         <div id="content">
            <p>▼ボタンをクリックすると、指定した透明度まで要素をフェードします。</p>
            <div id="sample"><img src="http://farm4.static.flickr.com/3222/2974008614_736e2d5b50.jpg" width="320" height="240" alt="くまさんケーキ" /></div>
            <p>
               <input type="button" id="btn_fadeto_0" value="fadeTo 0" />
               <input type="button" id="btn_fadeto_033" value="fadeTo 0.33" />
               <input type="button" id="btn_fadeto_05" value="fadeTo 0.5" />
               <input type="button" id="btn_fadeto_1" value="fadeTo 1" />
            </p>
         </div>
<!-- / CODE -->
      </div>
   </body>
</html>