JavaScript Reference/Javascript Methods/contains

Материал из Web эксперт
Перейти к: навигация, поиск

"contains()" Example

   <source lang="javascript">
   

<html> <body> <script language="JavaScript"> function function1() {

   var m = document.all.myDiv.contains(myB);
   if (m == true){ 
       m = "YES"
   } else {
       m = "NO"
   }
   alert(m)

} </script>

div element

<input id="myB" type="button" value="Is this button contained within the div element?" onclick="function1();">

</body> </html>


     </source>
   
  


"contains()" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |<a> <address> | | |<applet> <area> | | | <base> | | |<basefont> |

| |
<body> |

| |<button> |

| |
|

| | <col> | | |<colgroup> <custom> | | |

|

| |<dir>
| | |
| | | <embed> | | |<fieldset> | | |<form> <frame> | | |<frameset> <head> | | |<hn>
|

| |<html> | | |<iframe> <img> | | |<input type="button"> <input type="checkbox"> | | |<input type="file"> <input type="image"> | | |<input type="password"> <input type="radio"> | | |<input type="reset"> <input type="submit"> | | |<input type="text"> | | |<label> <legend> |

| |
  • <link> | | |<listing> <map> | | |<marquee> <menu> | | |<meta> <nobr> | | |
      <option> | | |

      <plaintext> | | |

                                                            |
      |                |                          <script>                      |
      |                |<select>                                               |
      |                |                                                |
      |                |                                                 |
      |                |                                                  |
      |                |<tbody>                                                   |
      |                |                                                       |
      |                |
        | | |<xmp> | +----------------+--------------------------------------------------------------+ </source>

        "contains()" Syntax, Parameters and Note

        <source lang="javascript"> Note: Is the parameter inside. Returns true or false.

        Syntax:

        document.all.elementID.contains(param1)

        Parameters: param1 Required; the element to check.


        </source>

      |

      | |<textarea> <tfoot> |

      | |
      <thead> | | |<title>