posts - 20,  comments - 2,  trackbacks - 0

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

          聲明:本文系JavaEye網(wǎng)站發(fā)布的原創(chuàng)博客文章,未經(jīng)作者書面許可,嚴禁任何網(wǎ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 姚文超 閱讀(142) 評論(0)  編輯  收藏

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


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 宁安市| 徐汇区| 塔城市| 赫章县| 邵阳市| 皮山县| 获嘉县| 海丰县| 东台市| 宜丰县| 桂平市| 静宁县| 乐安县| 连云港市| 绥江县| 新兴县| 南昌县| 原平市| 湟源县| 越西县| 波密县| 普格县| 荆门市| 图木舒克市| 山阴县| 泸水县| 安化县| 陈巴尔虎旗| 碌曲县| 石狮市| 友谊县| 鹤山市| 阳城县| 桐柏县| 昌吉市| 尚义县| 翁牛特旗| 黄石市| 平武县| 当雄县| 疏勒县|