首页 > 代码库 > ul+js模拟select

ul+js模拟select

html

 
css
.select_box{  float: left;}.select_box input{  width: 160px;  height: 30px;  text-align: center;  font-size: 18px;  color: #444;}.select_ul{  font-size: 14px;  text-align: center;  border: 1px solid #D2D3D3;}.select_ul li{  height: 50px;  line-height: 50px;}.select_ul li:hover{  background-color: #4EC0EC;}

  js

$(".select_box input").click(function(){      var thisinput=$(this);      var thisul=$(this).parent().find("ul");      if(thisul.css("display")=="none"){//        if(thisul.height()>200){thisul.css({height:"200"+"px","overflow-y":"scroll" })};        thisul.fadeIn("100");        thisul.hover(function(){},function(){thisul.fadeOut("100");})        thisul.find("li").click(function(){thisinput.val($(this).text());thisul.fadeOut("100");}).hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");});      }      else{        thisul.fadeOut("fast");      }    })//    $("#submit").click(function(){//      var endinfo="";//      $(".select_box input:text").each(function(i){//        endinfo=endinfo+(i+1)+":"+$(this).val()+";\n";//      })//      alert(endinfo);//    })

  

ul+js模拟select