実際のプロジェクトでは、getContent()でデータ収集をAjax Dynamic Acquisitionに変更できます。
<!doctype> <html> <head> <title> js/jqueryはBaidu検索機能に似ていることを実現しますキーボード "> <メタhttp-equiv =" content-type "content =" text/html; {位置:絶対;左:50%;トップ:40%;}#content {float:float:left; position:relative; right:50%;} input {border:0; width:288px; height:30px; font-size:16px; padding:0 5px; line-height:30px;}。 {背景:#87a900;}。ファースト{Border:Solid#87a900 2px; width:300px;}#append {border:solid#87a900 2px; border-top:0; display; onkeyup = "getContent(this);" /> </div> <div id = "append"> </div> </div> <スクリプトタイプ= "text/javascript"> var data = ["hello、michael"、 "who are you"、 "you are of are a a best"、 "you you are os my list fird"、 "you ou ou ou 'of my" of my "of my" of of of "of of"、 " Eye "]]; $(document).ready(function(){$(document).keydown(function(e){e = e || window.event; var keycode = e. e. e. e. e. e. e.keycode; if(keycode == 38){if(jquery.trim($("#append ")。html( (keycode == 40){if(jquery.trim($( "#append")。html())== ""){return;} $( "#kw")。 {$( "。アイテム")。removeclass( 'addbg')。eq(0).addclass( 'addbg');}} else if(keycode == 13){dojob();}}); var moveprev = function(}}); == 0){$( "。アイテム")。removeclass( 'addbg')。eq($( "。アイテム")。 $( "。addbg")。prevall()。length; if(index == $( "。item")。length -1){$( "。アイテム")。removeclass( 'addbg')。 1).addclass( 'addbg');}} var dojob = function(){$( "#kw")。blur(); var value = $( "。addbg")。text( "#kw")。val(value); $( "#append")。 jquery.trim($(obj).val()); if(kw == ""){$( "#append")。html( ""); return false;} var html = ""; for(var i = 0; i <data.length; i ++){if(kw)html+0) class = 'item' onmouseenter = 'getFocus' onclick = 'getCon(this);'> " + data [i] +" </div> "}} if(html!=" "){$("#append ")。show()。html(html); getFocus(obj){$( "。アイテム")。removeclass( "addbg"); $(obj).addclass( "addbg");} function getCon(obj){var value = $(obj).text(); $( "#kw")。val(value); $( "#append")。hid()。html( "");} </scrip> </body> </html>上記は、編集者によって導入されたJS Imitation Baidu自動ドロップダウンボックスのファジーマッチングプロンプトです。私はそれが誰にでも役立つことを願っています。ご不明な点がございましたら、メッセージを残してください。編集者は、すべての人に時間内に返信します!