欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS實(shí)現(xiàn)模糊查詢帶下拉匹配效果

 更新時(shí)間:2018年06月21日 09:58:09   作者:陌然嬿苒  
這篇文章主要介紹了JS實(shí)現(xiàn)模糊查詢帶下拉匹配效果,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

“搜索”可以使我們更快的找到某一個(gè)關(guān)鍵詞或者某一個(gè)商品,所以“模糊查詢”和“下拉匹配”也成了前端必備的一個(gè)小技能,開(kāi)門見(jiàn)山,希望對(duì)朋友們有幫助。

---搜索框模糊查詢帶下拉匹配效果html---

<!------------搜索框模糊查詢帶下拉匹配效果html---------------------->
<div class="gover_search">
  <div class="gover_search_form">
    <form action="#" method="post" name="searchform" id="searchform" class="searchinfo">
      <ul>
        <li>
          <input type="text" id="tt" value="" class="text" autocomplete="off" />
          <p class="search"><img src="img/search-1.png" alt=""></p>
          <p class="camera"><img src="img/camera.png" alt=""></p>
        </li>
        <li class="searchBtns-1"><img src="img/searchBtn.png" alt=""></li>
      </ul>
    </form>
  </div>
</div>

---搜索框模糊查詢帶下拉匹配效果-css---

.fl {float: left;}
.fr {float: right;}
.clearfix:after {  content: '';
  display: block;
  clear: both;
  visibility: hidden;
  height: 0;
}
.clearfix { zoom: 1}
.mar0 { margin: 0 auto;}
.pos1 {position: relative;}
input {
  border: none;
  outline: none;
}
.w100 {width: 100%;}
.gover_search{
 width: 420px;
 position: relative;
 border-radius: 20px;
 height: 42px;
 border: 2px solid #fb6910;
 background:#fff;
 margin-top: 50px;
 margin-left: 90px;
}
.searchinfo ul{
 list-style: none;
}
.gover_search_form {
 height: 37px;
 width: 420px;
 position: relative;
}
/*輸入框*/
.searchinfo .text{
 margin: 0;
 width: 334px;
 height: 38px;
 outline: none;
 vertical-align: middle;
 float: left;
 padding-left: 27px;
 line-height: 40px;
 margin-left: 16px;
}
/*搜索按鈕*/
.searchinfo .button {
 width: 120px;
 height: 40px;
 border: none;
 background-color: #4b140d;
 color: #fff;
 font-size: 19px;
 font-weight: bold;
 outline: none;
 float: left;
}
/*<!--隱藏的搜索框下拉列表-->*/
.bigautocomplete-layout{
 position: absolute;
 z-index: 999;
 left: 0px;
 max-height: 260px;
 overflow-y: auto;
 overflow-x: hidden;
 top: 213px !important;
 width: 336px !important;
 border: 1px solid #ccc;
 border-top: none;
 display: none;
 color: #004080;
 background-color: #fff;
}
.bigautocomplete-layout table{
 width:336px !important;
}
.bigautocomplete-layout table tr{
 margin-bottom:5px !important;
 cursor:pointer;
}
.bigautocomplete-layout table tr td{
 height: 25px !important;
 width: 336px !important;
 padding:0 10px !important;
 line-height: 25px !important;
}
.bigautocomplete-layout table tr:hover{
 background-color:#fb6910 !important;
 color:#fff;
}
.bigautocomplete-layout table tr:hover td div{
 color:#fff;
}
.bigautocomplete-layout table tr:hover td div span{
 color:#fff;
}
/*搜索框下拉列表關(guān)鍵字?jǐn)?shù)量*/
.keyRightSpan{
 float: right;
 display: block;
 width: auto;
 height: 25px !important;
 line-height: 25px !important;
 padding-right:8px
}
.ct{
 background-color: #fff;
}
/*關(guān)閉搜索框下拉列表按鈕*/
.search {
 width: 22px;
 height: 22px;
 position: absolute;
 top: 9px;
 left: 12px;
 z-index: 2;
}
.search img {
 width: 100%;
 height: 100%;
}
.camera {
 width: 22px;
 height: 22px;
 position: absolute;
 top: 9px;
 right: 80px;
 z-index: 2;
}
.camera img {
 width: 100%;
 height: 100%;
}
.searchBtn {
 width: 70px;
 height: 40px;
 position: absolute;
 top: 0px;
 right: 0px;
 z-index: 2;
}
.searchBtn img {
 width: 100%;
 height: 100%;
}

因?yàn)槭怯昧薭ootstrap框架,所以引入了bootstrap的樣式,自我調(diào)整哈<link rel="stylesheet" href="css/bootstrap.css" rel="external nofollow" >

樣式寫好以后就是js實(shí)現(xiàn)下來(lái)匹配了,最主要的是jquery.bigautocomplete.js的引入

<script src="js/jquery-3.1.1.js"></script>
<script src="js/index.js"></script>
<script src="js/jquery.bigautocomplete.js"></script>

---搜索框模糊查詢帶下拉匹配效果-js---

// 隱藏的搜索框下拉列表
$(function () {
  var num = 0;
  $("#tt").bigAutocomplete({
    width: 543,
    data: [{title: "牛欄山<span class='keyRightSpan'>約5個(gè)結(jié)果</span>", result: {ff: "qq"}},
      {title: "郎酒<span class='keyRightSpan'>約2個(gè)結(jié)果</span>"},
      {title: "茅臺(tái)<span class='keyRightSpan'>約4個(gè)結(jié)果</span>"},
      {title: "五糧液<span class='keyRightSpan'>約2個(gè)結(jié)果</span>"},
      {title: "水井坊<span class='keyRightSpan'>約7個(gè)結(jié)果</span>"},
      {title: "汾酒<span class='keyRightSpan'>約3個(gè)結(jié)果</span>"},
      {title: "洋府<span class='keyRightSpan'>約2個(gè)結(jié)果</span>"},
      {title: "董酒<span class='keyRightSpan'>約5個(gè)結(jié)果</span>"},
      {title: "劍南春<span class='keyRightSpan'>約2個(gè)結(jié)果</span>"},
      {title: "勁酒<span class='keyRightSpan'>約8個(gè)結(jié)果</span>"}],
    callback: function (data) {
      console.log(data.title);
    }
  });
})

接下來(lái)就是這個(gè)效果的截圖

可以鼠標(biāo)懸浮時(shí)選中某一個(gè)關(guān)鍵詞,然后點(diǎn)擊的時(shí)候把它的值(value)放在input框里

總結(jié)

以上所述是小編給大家介紹的JS實(shí)現(xiàn)模糊查詢帶下拉匹配效果,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • JS面向?qū)ο缶幊袒A(chǔ)篇(二) 封裝操作實(shí)例詳解

    JS面向?qū)ο缶幊袒A(chǔ)篇(二) 封裝操作實(shí)例詳解

    這篇文章主要介紹了JS面向?qū)ο缶幊谭庋b操作,結(jié)合實(shí)例形式詳細(xì)分析了JS面向?qū)ο蠓庋b操作的相關(guān)概念、原理、使用方法與操作注意事項(xiàng),需要的朋友可以參考下
    2020-03-03
  • 微信小程序?qū)崿F(xiàn)加入購(gòu)物車滑動(dòng)軌跡

    微信小程序?qū)崿F(xiàn)加入購(gòu)物車滑動(dòng)軌跡

    這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)加入購(gòu)物車滑動(dòng)軌跡,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-11-11
  • 微信小程序使用擴(kuò)展組件庫(kù)WeUI的入門教程

    微信小程序使用擴(kuò)展組件庫(kù)WeUI的入門教程

    WeUI是一套同微信原生視覺(jué)體驗(yàn)一致的基礎(chǔ)樣式庫(kù),由微信官方設(shè)計(jì)團(tuán)隊(duì)為微信內(nèi)網(wǎng)頁(yè)和微信小程序量身設(shè)計(jì),令用戶的使用感知更加統(tǒng)一,下面這篇文章主要給大家介紹了關(guān)于微信小程序使用擴(kuò)展組件庫(kù)WeUI的相關(guān)資料,需要的朋友可以參考下
    2022-04-04
  • ES6新特征數(shù)字、數(shù)組、字符串

    ES6新特征數(shù)字、數(shù)組、字符串

    這篇文章主要介紹了es6新特征之?dāng)?shù)字?jǐn)?shù)組和字符串的相關(guān)資料,需要的朋友可以參考下
    2016-10-10
  • uniApp常見(jiàn)面試題及答案(推薦!)

    uniApp常見(jiàn)面試題及答案(推薦!)

    uni-app是一個(gè)使用Vue.js開(kāi)發(fā)所有前端應(yīng)用的框架,下面這篇文章主要給大家介紹了關(guān)于uniApp常見(jiàn)面試題及答案的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-02-02
  • Nginx上傳文件全部緩存解決方案

    Nginx上傳文件全部緩存解決方案

    Nginx默認(rèn)會(huì)對(duì)上傳的文件先在本地進(jìn)行緩存,再轉(zhuǎn)發(fā)到應(yīng)用服務(wù)器。請(qǐng)問(wèn)怎么禁止掉這個(gè)緩存,讓Nginx只轉(zhuǎn)發(fā)而不緩存文件?本文給大家詳細(xì)介紹Nginx上傳文件全部緩存解決方案,有需要的朋友來(lái)參考下
    2015-08-08
  • javascript獲取ckeditor編輯器的值(實(shí)現(xiàn)代碼)

    javascript獲取ckeditor編輯器的值(實(shí)現(xiàn)代碼)

    這篇文章主要介紹了javascript獲取ckeditor編輯器的值,用于表單驗(yàn)證。需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助
    2013-11-11
  • javascript中使用replaceAll()函數(shù)實(shí)現(xiàn)字符替換的方法

    javascript中使用replaceAll()函數(shù)實(shí)現(xiàn)字符替換的方法

    第一次發(fā)現(xiàn)JavaScript中replace()?方法如果直接用str.replace("-","!")?只會(huì)替換第一個(gè)匹配的字符.
    2010-12-12
  • 微信小程序?qū)崿F(xiàn)張圖片合成為一張并下載

    微信小程序?qū)崿F(xiàn)張圖片合成為一張并下載

    這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)張圖片合成為一張并下載,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-07-07
  • js壓縮利器

    js壓縮利器

    這篇文章主要介紹了js壓縮利器
    2007-02-02

最新評(píng)論