JavaScript Reference/Javascript Methods/contains
"contains()" Example
<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 id="myDiv" style="width:300; height:100; border:solid; 1px blue">div element<br>
<input id="myB" type="button" value="Is this button contained within the div element?" onclick="function1();">
</div>
</body>
</html>
"contains()" is applied to
+----------------+--------------------------------------------------------------+
| Applied_To |<a> <address> |
| |<applet> <area> |
| |<b> <base> |
| |<basefont> <big> |
| |<blockquote> <body> |
| |<button> <caption> |
| |<center> <cite> |
| |<code> <col> |
| |<colgroup> <custom> |
| |<dd> <dfn> |
| |<dir> <div> |
| |<dl> <dt> |
| |<em> <embed> |
| |<fieldset> <font> |
| |<form> <frame> |
| |<frameset> <head> |
| |<hn> <hr> |
| |<html> <i> |
| |<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"> <kbd> |
| |<label> <legend> |
| |<li> <link> |
| |<listing> <map> |
| |<marquee> <menu> |
| |<meta> <nobr> |
| |<ol> <option> |
| |<p> <plaintext> |
| |<pre> <s> |
| |<samp> <script> |
| |<select> <small> |
| |<span> <strike> |
| |<strong> <sub> |
| |<sup> <table> |
| |<tbody> <td> |
| |<textarea> <tfoot> |
| |<th> <thead> |
| |<title> <tr> |
| |<tt> <u> |
| |<ul> <var> |
| |<xmp> |
+----------------+--------------------------------------------------------------+
"contains()" Syntax, Parameters and Note
Note:
Is the parameter inside.
Returns true or false.
Syntax:
document.all.elementID.contains(param1)
Parameters:
param1 Required; the element to check.