'contains()' Example : contains « Node Operation « JavaScript DHTML






'contains()' Example

    
<html>
<body>
<script language="JavaScript">
function function1() {
    var flag = document.all.myDiv.contains(myB);
    if (flag == true){ 
        flag = "YES"
    } else {
        flag = "NO"
    }
    alert(flag)
}
</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