日期:2014-05-16  浏览次数:20360 次

JS 实现div的切换
?<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>莫得标题</title>
<style type="text/css">
ul{ list-style:none}
</style>
<SCRIPT language=JavaScript>
    var nFocus = 0;
    var bFlag = false;
    var aLiTab, aDivTab;
    function c1() {
            var $ = function c($) {
                return document.getElementById($);
            };
           aLiTab = $("oUlTab").getElementsByTagName("li");
           aDivTab = [$("oDivTab1"), $("oDivTab2"), $("oDivTab100"), $("oDivTab3")];
       
        for (var i = 0; i < aLiTab.length; i++) {
            (
            function(i)
{
                   var t = aLiTab[i];
                   t.onclick = function c() {
                   if (nFocus != i) {
                        aLiTab[nFocus].className = "";
                        aDivTab[nFocus].style.display = "none";
                        nFocus = i;
                        aLiTab[nFocus].className = "on";
                        aDivTab[nFocus].style.display = "";
              }
                 bFlag = true;
               };
               t.onmouseout = function c() {
                bFlag = false;
            };
                 }
            ) (i);
        }
    };


</SCRIPT>


<script type="text/javascript">
    window.onload = function() {
       c1();
}
</script>

    </head>
    <body>
[align=top" st