茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    Jquery插件仿百度搜索關(guān)鍵字自動(dòng)匹配功能
    來源:易賢網(wǎng) 閱讀:1805 次 日期:2016-07-01 14:17:36
    溫馨提示:易賢網(wǎng)小編為您整理了“Jquery插件仿百度搜索關(guān)鍵字自動(dòng)匹配功能”,方便廣大網(wǎng)友查閱!

    這篇文章主要為大家詳細(xì)介紹了Jquery插件仿百度搜索關(guān)鍵字自動(dòng)匹配功能的相關(guān)資料,需要的朋友可以參考下

    本文實(shí)例為大家分享了Jquery搜索關(guān)鍵字自動(dòng)匹配功能的實(shí)現(xiàn)代碼,供大家參考,具體內(nèi)容如下

    jQuery AutoComplete 是一個(gè)基于jQuery實(shí)現(xiàn)搜索關(guān)鍵字自動(dòng)匹配提示的插件,該插件可擴(kuò)展性強(qiáng),表現(xiàn)性能優(yōu)越,方便整合到自己的項(xiàng)目中使用;兼容IE 6.0+, FF 2+, Safari 2.0+, Opera 9.0+, and Chrome 1.0+ 等主流瀏覽器。

    下面是具體的使用方法:

    1、使用設(shè)置

    首頁,要把插件的js代碼嵌入到你自己的項(xiàng)目中去。

    代碼如下:

    <script src="jquery.js" type="text/javascript"><!--mce:0--></script><script src="jquery.autocomplete.js" type="text/javascript"><!--mce:1--></script>

    2、使用方法

    為要實(shí)現(xiàn)自動(dòng)匹配提示的 input 表單添加 AutoComplete 功能。

    <input id="query" name="q" />

    初始化 AutoComplete 對(duì)象,確保正確加載 DOM 對(duì)象,否則IE下的用戶可能會(huì)出現(xiàn)錯(cuò)誤。

    代碼如下:

    $('#query').autocomplete({ serviceUrl: 'service/autocomplete.ashx', // Page for processing autocomplete requests minChars: 2, // Minimum request length for triggering autocomplete delimiter: /(,|;)\s*/, // Delimiter for separating requests (a character or regex) maxHeight: 400, // Maximum height of the suggestion list, in pixels width: 300, // List width zIndex: 9999, // List's z-index deferRequestBy: 0, // Request delay (milliseconds), if you prefer not to send lots of requests while the user is typing. I usually set the delay at 300 ms. params: { country: 'Yes'}, // Additional parameters onSelect: function(data, value){ }, // Callback function, triggered if one of the suggested options is selected, lookup: ['January', 'February', 'March'] // List of suggestions for local autocomplete });

    根據(jù)文本表單中的輸入信息,進(jìn)行關(guān)鍵字提示匹配。

    代碼如下:

    { query:'Li', // Original request suggestions:['Liberia','Libyan Arab Jamahiriya','Liechtenstein','Lithuania'], // List of suggestions data:['LR','LY','LI','LT'] // Optional parameter: list of keys for suggestion options; used in callback functions. }

    jQuery AutoComplete 插件支持 on/off功能,從而控制效果的開關(guān)。

    代碼如下:

    var ac = $('#query').autocomplete({ /*parameters*/ }); ac.disable(); ac.enable(); ac.setOptons({ zIndex: 1001 });

    3、設(shè)置表現(xiàn)樣式

    最后,用div和css美化表現(xiàn)效果。

    代碼如下:

    <div class="autocomplete-w1"><div id="Autocomplete_1240430421731" class="autocomplete" style="width: 299px;"><div><strong>Li</strong>beria</div><div><strong>Li</strong>byan Arab Jamahiriya</div><div><strong>Li</strong>echtenstein</div><div class="selected"><strong>Li</strong>thuania</div></div></div> .autocomplete-w1 { background:url(img/shadow.png) no-repeat bottom right; position:absolute; top:0px; left:0px; margin:6px 0 0 6px; /* IE6 fix: */ _background:none; _margin:1px 0 0 0; }.autocomplete { border:1px solid #999; background:#FFF; cursor:default; text-align:left; max-height:350px; overflow:auto; margin:-6px 6px 6px -6px; /* IE6 specific: */ _height:350px; _margin:0; _overflow-x:hidden; }.autocomplete .selected { background:#F0F0F0; }.autocomplete div { padding:2px 5px; white-space:nowrap; overflow:hidden; }.autocomplete strong { font-weight:normal; color:#3399FF; }

    4、實(shí)例講解

    <html>

    <head>

     <title></title>

     <style type="text/css">

     #txtKey{ width:300px;}

     </style>

     <link href="css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />

     <script src="Jquery1.7.js" type="text/javascript"></script>

     <script src="js/jquery.autocomplete.js" type="text/javascript"></script>

     <script type="text/javascript">

      $(function () {

       var array = ['asp.net', 'asp.net mvc', 'wcf', 'wpf', 'win8', 'windows phone', '張東', '張熙', '張亞飛'];

       /*autocomplete函數(shù)

       (1)獲取txtKey中用戶輸入的值(用戶每輸入一個(gè)字符,都會(huì)獲取一次)

       (2)將獲取的值和array集合中的元素進(jìn)行比較,找出匹配的元素,并顯示出來

       (3)會(huì)將用戶選擇的項(xiàng)添加到txtKey中*/

       /*result函數(shù):對(duì)用戶選擇的結(jié)果進(jìn)行操作。data參數(shù)表示用戶選擇的項(xiàng)*/

       $('#txtKey').autocomplete(array).result(function (event, data) { window.location. + data + '&rsv_bp=0&ch=&tn=baidu&bar=&rsv_spt=3&ie=utf-8&rsv_sug3=6&rsv_sug=0&rsv_sug1=3&rsv_sug4=229&inputT=1458'; })

      })

     </script>

    </head>

    <body>

     <input id="txtKey" type="text" /><input id="Button1" type="button" value="百度一下" />

     <input id="Text1" type="text" />

    </body>

    </html>

    實(shí)現(xiàn)效果如下:

    名單

    以上就是關(guān)于jQuery AutoComplete使用方法介紹,通過完整示例為大家展示jQuery AutoComplete使用效果,希望對(duì)大家的學(xué)習(xí)有所幫助。

    更多信息請(qǐng)查看網(wǎng)絡(luò)編程
    易賢網(wǎng)手機(jī)網(wǎng)站地址:Jquery插件仿百度搜索關(guān)鍵字自動(dòng)匹配功能
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2026上岸·考公考編培訓(xùn)報(bào)班

    • 報(bào)班類型
    • 姓名
    • 手機(jī)號(hào)
    • 驗(yàn)證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn) | 投訴建議
    工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報(bào)警專用圖標(biāo)