Get tags by name : getElementsByName « Node Operation « JavaScript DHTML






Get tags by name

  

<html>
<head>
<title></title>
<script type="text/javascript">
function findName() {
   var typeStr = "";
   var nmStr = "elem1";
   var nmList = document.getElementsByName(nmStr);
   typeStr += nmList[0].tagName + " ";
   alert(typeStr);
}
</script>
</head>
<body onload="findName();">
<div name="elem1">
    <ul name="elem2">
        <li>option 1</li>
        <li name="elem3">option 2</li>
    </ul>
</div>
<p name="elem5">Paragraph</p>
<form name="elem6">
    <input type="text" name="elem7" />
</form>
</body>
</html>

   
    
  








Related examples in the same category

1.'getElementsByName()' Example