Check if a tag exists : all « Document « JavaScript DHTML






Check if a tag exists

 


<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
function findhead1() 
{
    var detectElement = document.all("head1");
    if (detectElement == head1) 
    {
        alert("Element \'head1\' exists");
    }
}
</script>
</head>
<body onload="findhead1()">
<h1 id="head1">Heading One</h1>
</body>
</html>

   
  








Related examples in the same category