HTML DOM tabIndex 属性

定义和用法

tabIndex 属性可设置或返回某个区域的 tab 键控制次序。

语法

  1. areaObject.tabIndex=tabIndex

实例

下面的例子可展示图像映射中区域的 tab 键控制次序:

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function showTabIndex()
  5. {
  6. var sun=document.getElementById('sun').tabIndex;
  7. var mercury=document.getElementById('mercury').tabIndex;
  8. var venus=document.getElementById('venus').tabIndex;
  9.  
  10. document.write("Tab index of Sun: " + sun);
  11. document.write("<br />");
  12. document.write("Tab index of Mercury: " + mercury);
  13. document.write("<br />");
  14. document.write("Tab index of Venus: " + venus);
  15. }
  16. </script>
  17. </head>
  18. <body>
  19.  
  20. <img src ="planets.gif"
  21. width="145" height="126"
  22. alt="Planets"
  23. usemap ="#planetmap" />
  24.  
  25. <map name="planetmap">
  26. <area shape ="rect" coords ="0,0,82,126"
  27. href ="sun.htm" id="sun" tabIndex="1" />
  28. <area shape ="circle" coords ="90,58,3"
  29. href ="mercur.htm" id="mercury" tabIndex="2" />
  30. <area shape ="circle" coords ="124,58,8"
  31. href ="venus.htm" id="venus" tabIndex="3" />
  32. </map>
  33.  
  34. <input type="button" onclick="showTabIndex()"
  35. value="Show tabIndex" />
  36.  
  37. </body>
  38. </html>