Element name and id : id « Javascript Properties « JavaScript DHTML






Element name and id

 

<html>
<head>
<title>A Simple Page</title>
<script language="JavaScript">
function tagInfo() 
{
    var tag;
    tag = "Name:" + window.event.srcElement.tagName + " ID:" + window.event.srcElement.id;
    window.status = tag;
}
</script>
</head>
<body onMouseover="tagInfo()" id="body1">
    <h1 id="head1">Heading One</h1>
    <p id="para1">Some text</p>
</body>
</html>

   
  








Related examples in the same category

1.Parent Tag name