'index' Example : index « Javascript Properties « JavaScript Reference





'index' Example

    
<html>
<body>
<select id="myS" size=5>
   <option id="o1">1</option>
   <option id="o2">2</option>
   <option id="o3">3</option>
   <option id="o4">4</option>
   <option id="o5">5</option>
</select>
<input type="button" value="1" onClick="function1(o1);">
<input type="button" value="2" onClick="function1(o2);">
<input type="button" value="3" onClick="function1(o3);">
<input type="button" value="4" onClick="function1(o4);">
<input type="button" value="5" onClick="function1(o5);">
<script language="JavaScript">
    function function1(elem) {
        alert("Index: "+ elem.index);
    }
</script>
</body>
</html>

    
      
      










Related examples in the same category

1.'index' Syntax and Note
2.'index' is applied to