1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    2. "http://www.w3.org/TR/html4/loose.dtd">
    3. <html>
    4. <head>
    5. <title>15-2Style??Class??????</title>
    6. <style type="text/css">
    7. #tab{
    8. width: 400px;
    9. }
    10. #tab ul{
    11. list-style: none; overflow: hidden; margin: 0px; padding: 0px;
    12. }
    13. #tab ul li.cur{
    14. background-color: green;
    15. }
    16. #tab .content{
    17. width: 100%; border: 1px solid #eeeeee; height: 100px;
    18. }
    19. </style>
    20. <script type="text/javascript">
    21. window.onload = function () {
    22. //???��??????
    23. var olis = document.getElementsByTagName("li");
    24. for(var i=0; i<olis.length; i++){
    25. olis[i].index = i;
    26. olis[i].onmousemove = function () {
    27. for (var j =0; j<olis.length; j++){
    28. document.getElementById("content-"+ j).style.display = "none";
    29. olis[j].className=""
    30. //?????��??? ???? this
    31. document.getElementById("content-"+ this.index).style.display = "block";
    32. olis[this.index].className="cur"
    33. }
    34. }
    35. }
    36. }
    37. </script>
    38. </head>
    39. <body>
    40. <div id = "tab">
    41. <ul>
    42. <li class="cur">???1</li>
    43. <li>???2</li>
    44. </ul>
    45. <div id="c-box">
    46. <div class="content" id="content-0">???one</div>
    47. <div class="content" id="content-1">???two</div>
    48. </div>
    49. </div>
    50. </body>
    51. </html>