Prototype - Object isElement() Method


Advertisements


This method returns true if obj is a DOM node of type 1, false otherwise.

Syntax

Object.isElement(obj);

Return Value

Returns true if the passed object is a DOM node of type 1, otherwise returns false.

Example

<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>

Output


prototype_basic_object.htm

Advertisements