posts - 20,  comments - 2,  trackbacks - 0

          作者: tianshi0253  鏈接:http://tianshi0253.javaeye.com/blog/204995  發(fā)表時間: 2008年06月18日

          聲明:本文系JavaEye網站發(fā)布的原創(chuàng)博客文章,未經作者書面許可,嚴禁任何網站轉載本文,否則必將追究法律責任!

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
            <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
            <title>my select</title>
            <style type="text/css">
            <!--
              body
              {
                margin: 0px;
                padding: 30px 0px 0px 30px;
                background-color: #CFDFEF;
                font-size: 12px;
              }
              .selectA
              {
                width: 92px;
                height: 17px;
                padding-left: 10px;
                padding-top: 5px;
                background-image: url(http://labs.utombox.com/select2css/tm2008-select.gif);
                overflow: hidden;
                cursor: pointer;
              }
              .selectB
              {
                display: none;
                width: 81px;
                height: auto;
                background-image: url(http://labs.utombox.com/select2css/tm2008-select.gif);
                background-position: -102px 0px;
                border-bottom: 1px solid #4EA0D1;
              }
              .selectB .item
              {
                width: 71px;
                height: 17px;
                background-image: url(http://labs.utombox.com/select2css/tm2008-select.gif);
                background-position: -102px 0px;
                padding-left: 10px;
                padding-top: 5px;
                overflow: hidden;
                cursor: pointer;
              }
            -->
            </style>
            <script type="text/javascript">
            <!--
              //val
              var items = null;
              var selectA = null;
              var selectB = null;
              var selectAClicked = false;
          
              //method
              function $(s)
              {
                return document.getElementById(s);
              }
          
              window.onload = function()
              {
                items = [$("itemA"),$("itemB"),$("itemC"),$("itemD"),$("itemE"),$("itemF"),$("itemG"),$("itemH")];
                selectA = $("selectA");
                selectB = $("selectB");
                //init
                items[0].style.backgroundPosition = "0px -66px";
                //selectA event
                selectA.onmouseover = function()
                {
                  if(selectAClicked)
                    return;
                  this.style.backgroundPosition = "0px -22px";
                }
                selectA.onmouseout = function()
                {
                  if(selectAClicked)
                    return;
                  this.style.backgroundPosition = "0px 0px";
                }
                selectA.onclick = function()
                {
                  if(selectAClicked)
                  {
                    selectAClicked = false;
                    this.style.backgroundPosition = "0px -22px";
                    selectB.style.display = "none";
                    return;
                  }
                  selectAClicked = true;
                  this.style.backgroundPosition = "0px -44px";
                  selectB.style.display = "block";
                }
                //selectB event
                //none
                //items event
                function itemMouseOver()
                {
                  this.style.backgroundPosition = "0px -88px";
                }
                function itemMouseOut()
                {
                  if(this.innerHTML == selectA.innerHTML)
                  {
                    this.style.backgroundPosition = "0px -66px";
                    return;
                  }
                  this.style.backgroundPosition = "-102px 0px";
                }
                function itemClick()
                {
                  for(var i=0,length=items.length;i<length;i++)
                    items[i].style.backgroundPosition = "-102px 0px";
                  this.style.backgroundPosition = "0px -66px";
                  selectA.innerHTML = this.innerHTML;
                  selectB.style.display = "none";
                  selectA.style.backgroundPosition = "0px 0px";
                  selectAClicked = false;
                }
                for(var i=0,length=items.length;i<length;i++)
                {
                  items[i].onmouseover = itemMouseOver;
                  items[i].onmouseout = itemMouseOut;
                  items[i].onclick = itemClick;
                }
              }
            //-->
            </script>
          </head>
          
          <body>
          
          <div class="selectA" id="selectA">itemA</div>
          <div class="selectB" id="selectB">
            <div class="item" id="itemA">itemA</div>
            <div class="item" id="itemB">itemB</div>
            <div class="item" id="itemC">itemC</div>
            <div class="item" id="itemD">itemD</div>
            <div class="item" id="itemE">itemE</div>
            <div class="item" id="itemF">itemF</div>
            <div class="item" id="itemG">itemG</div>
            <div class="item" id="itemH">itemH</div>
          </div>
          
          </body>
          </html>

           


          本文的討論也很精彩,瀏覽討論>>


          JavaEye推薦




          文章來源:http://tianshi0253.javaeye.com/blog/204995
          posted on 2008-06-18 09:09 姚文超 閱讀(241) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。


          網站導航:
           
          主站蜘蛛池模板: 凌海市| 车险| 华亭县| 无棣县| 牡丹江市| 乌拉特中旗| 德清县| 搜索| 鄄城县| 云梦县| 醴陵市| 崇州市| 沅陵县| 麻城市| 伊川县| 蒲江县| 博兴县| 宿松县| 垣曲县| 青田县| 资溪县| 敦化市| 山阴县| 博乐市| 六盘水市| 海阳市| 元江| 凤台县| 金川县| 教育| 合山市| 平山县| 禹城市| 酉阳| 清镇市| 精河县| 彩票| 苏尼特右旗| 沐川县| 芦山县| 紫金县|