JavaScript Reference/Javascript Methods/contains
"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>
<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>
| | | | | |
| |<dir><col> | | |<colgroup> <custom> | | |
| | | |
- | | | <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>
| | |<textarea> <tfoot> |
| |<thead> | | |<title> | | | | | | | | |<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>