tabs.js 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. window.onload = function() {
  2. var oDiv = document.getElementById("tab");
  3. var oLi = oDiv.getElementsByTagName("div")[0].getElementsByTagName("li");
  4. var aCon = oDiv.getElementsByTagName("div")[1].getElementsByTagName("div");
  5. var timer = null;
  6. for (var i = 0; i < oLi.length; i++) {
  7. oLi[i].index = i;
  8. oLi[i].onmouseover = function() {
  9. show(this.index);
  10. }
  11. }
  12. function show(a) {
  13. index = a;
  14. var alpha = 0;
  15. for (var j = 0; j < oLi.length; j++) {
  16. oLi[j].className = "";
  17. aCon[j].className = "";
  18. aCon[j].style.opacity = 0;
  19. aCon[j].style.filter = "alpha(opacity=0);";
  20. }
  21. oLi[index].className = "cur";
  22. clearInterval(timer);
  23. timer = setInterval(function() {
  24. alpha += 2;
  25. alpha > 100 && (alpha = 100);
  26. aCon[index].style.opacity = alpha / 100;
  27. aCon[index].style.filter = "alpha(opacity=" + alpha + ")";
  28. alpha == 100 && clearInterval(timer);
  29. },
  30. 5)
  31. }
  32. }