首页 >web前端 >js教程 >js模拟select下拉菜单控件的代码_javascript技巧

js模拟select下拉菜单控件的代码_javascript技巧

WBOY
WBOY原创
2016-05-16 17:34:27930浏览
复制代码 代码如下:


 
 
 
 
 js模拟select
 
   
 
  

          

            

                

select选择


                
                

                        
  • jq的select模拟1

  •                     
  • jq的select模拟2

  •                     
  • jq的select模拟3

  •                 

            

            

                

select选择2


                
                

                        
  • jq的select模拟11

  •                     
  • jq的select模拟22

  •                     
  • jq的select模拟31

  •                 

            


        

 

   <script><br><br> window.onload=function(){<BR> var oflink = document.getElementById('sel');<BR> var aDt = oflink.getElementsByTagName('dt');<BR> var aUl = oflink.getElementsByTagName('ul');<BR> var aH3= oflink.getElementsByTagName('h3');<BR> for(var i=0;i<aDt.length;i++){<BR> aDt[i].index = i;<BR> aDt[i].onclick = function(ev){<BR> var ev = ev || window.event;<BR> var This = this;<BR> for(var i=0;i<aUl.length;i++){<BR> aUl[i].style.display = 'none';<BR> }<BR> aUl[this.index].style.display = 'block';<BR> document.onclick = function(){<BR> aUl[This.index].style.display = 'none';<BR> };<BR> ev.cancelBubble = true;<br><br> };<BR> }<BR> for(var i=0;i<aUl.length;i++){<br><br> aUl[i].index = i;<br><br> (function(ul){<br><br> var iLi = ul.getElementsByTagName('li');<br><br> for(var i=0;i<iLi.length;i++){<BR> iLi[i].onmouseover = function(){<BR> this.className = 'hover';<BR> };<BR> iLi[i].onmouseout = function(){<BR> this.className = '';<BR> };<BR> iLi[i].onclick = function(ev){<BR> var ev = ev || window.event;<BR> aH3[this.parentNode.index].innerHTML = this.innerHTML;<BR> ev.cancelBubble = true;<BR> this.parentNode.style.display = 'none';<BR> };<BR> }<br><br> })(aUl[i]);<BR> }<br><br> }<BR> </script>

 
 
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn