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

実行結果

abelOver | 設置サンプル

Example without labelOver

ページの読み込み時にラベルの内容が入力欄に表示されます。クリックすると消えます。また、フォーカスを外しても入力欄に何かテキストが入力されるまで表示されます。

Example without labelOver

ボタンをクリックすると、ラベルの内容が入力欄にグレーアウト表示されます。

設置サンプルのソース

<!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>labelOver | 設置サンプル</title>
      <link rel="stylesheet" type="text/css" href="/content/lib/global.css" />
      <!-- JS -->
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
      <script type="text/javascript" src="/content/lib/jquery/jquery.label_over.js"></script> 
      <script type="text/javascript">
         $(function() {
            $('#frm').submit(function() {
               $('legend', this).html('Example with labelOver');
               return false;
            })
            $('#frm2').submit(function() {
               $('legend', this).html('Example with labelOver');
               $('label').labelOver('over');
               return false;
            })
            $('#frm label.pre').labelOver('over');
         });
      </script>
      <!-- CSS -->
      <style type="text/css">
            textarea { width:80%;}
            fieldset { border:1px solid #ccc; padding:1em; margin:0 0 20px 0; }
            legend { color:#ccc; font-size:120%; }
            input, textarea { display:block; clear:left; font-family:Arial, verdana; font-size:125%; padding:7px; border:1px solid #999; margin:10px; }
            div.label { position:relative; float:left; margin-right:3px; font-weight:bold; }
            div.clear { clear:both; }
            label.over { color:#ccc; position:absolute; top:20px; left:20px;}
      </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><a href='http://remysharp.com/2007/03/19/a-few-more-jquery-plugins-crop-labelover-and-pluck/'>abelOver</a> | 設置サンプル</h1>
<!-- CODE -->
           <form action="#" id="frm">
            <fieldset>
               <legend>Example without labelOver</legend>
               <div class="label">
                  <label class="pre" for="username">ユーザー名</label>
                  <input type="text" name="username" value="" id="username" />
               </div>
               <div class="label">
                  <label class="pre" for="password">パスワード</label>
                  <input type="text" name="password" value="" id="password" />
               </div>
               <div style="float:left;">
                  <input type="submit" value="Login" />
               </div>
               <div class="clear"></div>
               <p>ページの読み込み時にラベルの内容が入力欄に表示されます。クリックすると消えます。また、フォーカスを外しても入力欄に何かテキストが入力されるまで表示されます。</p>
            </fieldset>
         </form>
           <form action="#" id="frm2">
            <fieldset>
               <legend>Example without labelOver</legend>
               <div class="label">
                  <label for="search">Search</label>
                  <input type="text" name="search" value="" id="search" />
               </div>
               <input type="submit" name="submit" value="Apply label over" id="submit" />
               <div class="clear"></div>
               <p>ボタンをクリックすると、ラベルの内容が入力欄にグレーアウト表示されます。</p>
            </fieldset>
           </form>
<!-- / CODE -->
      </div>
   </body>
</html>