手写select,解决浏览器兼容性

html

<div class="top_search">
     <div class="search_sel">
          <p class="search_sel_show">搜<span>商品</span><b></b></p>
          <ul class="seatch_sel_list">
               <li>商品</li>
               <li>店铺</li>
          </ul>
     </div>
     <div class="search_con">
          <input type="text" class="search_con_input" placeholder="雪纺" aria-label="雪纺" />
          <input type="button" value="搜索" class="search_con_btn" />
     </div>
</div>
css

/*搜索条*/
.top_search{
    float: left;
    margin-left: 230px;
    margin-top: 32px;
    height: 34px;
    line-height: 34px;
    border:1px solid #f2572c;
}
.top_search>div{
    float: left;
    background: #fff
}
.search_sel{
    position: relative;
    cursor: pointer; 
}
.search_sel_show{
    padding:0 12px;
    color: #f2572c;
    position: relative;
    width: 55px;
}
.search_sel_show>b{
    position: absolute;
    top:16px;right: 10px;
    width: 20px;
    height: 10px;
    background:url(../../image/sprites.png) no-repeat -40px -208px;
}
.seatch_sel_list{
    position: absolute;
    top:35px;left:-1px;
    z-index: 500;
    width: 78px;
    border: 1px solid #D2D2D2;
    border-top: none;
    text-align: center;
    background-color: #fff;
    display: none;
}
.seatch_sel_list>li{
    line-height: 34px;
}
.search_con{
    position: relative;
}
.search_con_input{
    height: 30px;
    line-height: 30px;
    width: 300px;
    padding-right: 100px;
    text-indent: 8px;
    outline: none;
}
.search_con_btn{
    position: absolute;
    top:0px;right: 0px;
    width: 100px;
    height: 34px;
    line-height: 30px;
    text-align: center;
    color: #fff;
    background-color: #f2572c;
    font-size: 16px;
    outline: none;
    cursor: pointer;
}
/*end 搜索条*/


js

    // 搜索下拉
    $(".search_sel_show").on("click",function(){
      var list=$(this).next(),
        listShow=list.css("display")
      if(listShow=="none"){
        list.slideDown();
      }else{
        list.slideUp();
      }
    });
    $(".seatch_sel_list").on("click","li",function(){
      var txt=$(this).text();
      $(".search_sel_show>span").text(txt);
      $(this).parent().slideUp();
    });


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值