▼入力欄には、入力のヒントとなるテキストが表示されています。このヒントテキストは入力欄をクリックすると消えます。入力欄からフォーカスを外すと、入力欄が空の場合、ヒントテキスト以外のテキストが入力されていない場合、送信後は、再度ヒントテキストが表示されます。
<!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.3.2/jquery.min.js"></script> <script type="text/javascript" src="/content/lib/jquery/jquery.overlabel.js"></script> <script type="text/javascript"> $(function(){ $("label.overlabel").overlabel(); }); </script> <!-- CSS --> <style type="text/css"> fieldset div { position:relative; float:left; margin:10px 5px 0 0; padding:0; } input#username-field, input#password-field { width:10em; padding:5px; } label.overlabel { color:#999; } label.overlabel-apply { position:absolute; top:3px; left:5px; z-index:1; color:#999; } </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 & JavaScript Room</a> :: 設置サンプル</h1> <h3 class='h'>実行結果</h3> <div id="wrap"> <h1 id='a_toggleformtext'><a href='http://grzegorz.frydrychowicz.net/jquery_toggleformtext/'>ToggleFormText plug-in</a> | 設置サンプル</h1> <p>▼入力欄には、入力のヒントとなるテキストが表示されています。このヒントテキストは入力欄をクリックすると消えます。入力欄からフォーカスを外すと、入力欄が空の場合、ヒントテキスト以外のテキストが入力されていない場合、送信後は、再度ヒントテキストが表示されます。</p> <!-- CODE --> <form id="login" action="#" method="post"> <fieldset> <legend>ログインフォーム</legend> <div id="username"> <label for="username-field" class="overlabel">Username</label> <input id="username-field" type="text" name="username" title="Username" value="" /> </div> <div id="password" class="overlabel-wrapper"> <label for="password-field" class="overlabel">Password</label> <input id="password-field" type="password" name="password" title="Password" value="" /> </div> <div id="submit"> <input type="submit" name="submit" value="ログイン" /> </div> </fieldset> </form> <!-- / CODE --> </div> </body> </html>