Prototype-object-iselement

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

プロトタイプ-オブジェクトisElement()メソッド

このメソッドは、objがタイプ1のDOMノードである場合はtrueを返し、そうでない場合はfalseを返します。

構文

Object.isElement(obj);

戻り値

渡されたオブジェクトがタイプ1のDOMノードである場合はtrueを返し、そうでない場合はfalseを返します。

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

      <script>
         function showResult() {
            alert( "1: " + Object.isElement(new Element('div')) );
            alert( "2: " + Object.isElement(document.createElement('div')) );
            alert( "3: " + Object.isElement(document.createTextNode('foo')) );
            alert( "4: " + Object.isElement($('para')) );
         }
      </script>
   </head>

   <body>
      <p id = "para">Click the button to see the result.</p>
      <br/>
      <br/>
      <input type = "button" value = "Result" onclick = "showResult();"/>
   </body>
</html>

出力