not a proper naming convention but it's working fine, How and what is need of naming conventions if it works?

Posted by Pravallika69 on Stack Overflow See other posts from Stack Overflow or by Pravallika69
Published on 2012-04-13T05:08:59Z Indexed on 2012/04/13 5:28 UTC
Read the original article Hit count: 117

Filed under:
|

I'm new to javascript programming. I have found below example while practicing javascript.

<html>
<head>
<script type="text/javascript">
function changeTabIndex()
  {
  document.getElementById('1').tabIndex="3"
  document.getElementById('2').tabIndex="2"
  document.getElementById('3').tabIndex="1"
  }
</script>
</head>
<body>

<p><a id="1" href="http://www.w3schools.com">1</a></p>
<p><a id="2" href="http://www.w3schools.com">2</a></p>
<p><a id="3" href="http://www.w3schools.com">3</a></p>

<input type="button" onclick="changeTabIndex()"
value="Change TabIndex" />

</body>
</html>  

What's my doubt is, naming conventions for id attribute must start with an alphabet followed by numbers and underscore. But in this example even though they used numbers as id's the code working fine.Then what is the need of following naming conventions. It seems to be simple but anyone please clarify it.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html