'contains()' Example : contains « Javascript Methods « JavaScript Reference

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

    
      
      








Related examples in the same category

1.'contains()' Syntax, Parameters and Note
2.'contains()' is applied to