Prototype-form-element-select

提供:Dev Guides
移動先:案内検索

プロトタイプ-Form.Element select()メソッド

このメソッドは、テキスト入力で現在のテキストを選択します。

構文

formElement.select();

戻り値

選択されたHTML要素を返します。

<html>
   <head>
      <title>Prototype examples</title>
      <script type = "text/javascript" src = "/javascript/prototype.js"></script>

      <script>
         function showResult() {
            var elem = $('searchbox');
            Form.Element.select(elem)
         }
      </script>
   </head>

   <body>
      <p>Enter some value click the button to see the result.</p>
      <br/>

      <form id = "example" action = "#">
         <fieldset>
            <div>
               <label for = "searchbox">Search</label>
               <input id = "searchbox" name = "searchbox" type = "text">
            </div>
            <div>
               <input value = "Result" type = "button" onclick = "showResult();">
            </div>
         </fieldset>
      </form>

   </body>
</html>

出力