2015-12-09 30 views
0

我希望只要用戶點擊表單輸入,就會出現默認的選項列表,例如, Refer practo如何在Jquery自動填充插件中顯示默認建議?

點擊專科,醫生診所等。我該怎麼做?

+1

請寫什麼你嘗試過。 –

+0

您是否使用ajax調用來填寫自動完成? –

+0

[jquery自動完成觸發器下拉輸入:焦點]可能的重複(http://stackoverflow.com/questions/11168446/jquery-autocomplete-trigger-dropdown-on-inputfocus) – madalinivascu

回答

0
$("#tags") 
    .autocomplete({ 
     source: availableTags 
    }).on('focus', function(){ $(this).autocomplete("instance").search("a"); }); 

會工作,而不是 「自動完成(」 搜索 「),」 全部代碼如下

<!doctype html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <title>jQuery UI Autocomplete - Default functionality</title> 
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> 
    <script src="http://code.jquery.com/jquery-1.10.2.js"></script> 
    <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script> 

    <script> 

    $(function() { 
    var availableTags = [ 
     "ActionScript", 
     "AppleScript", 
     "Asp", 
     "BASIC", 
     "C", 
     "C++", 
     "Clojure", 
     "COBOL", 
     "ColdFusion", 
     "Erlang", 
     "Fortran", 
     "Groovy", 
     "Haskell", 
     "Java", 
     "JavaScript", 
     "Lisp", 
     "Perl", 
     "PHP", 
     "Python", 
     "Ruby", 
     "Scala", 
     "Scheme" 
    ]; 
    $("#tags") 
    .autocomplete({ 
     source: availableTags 
    }).on('focus', function(){ $(this).autocomplete("instance").search("a"); }); 

    }); 
    </script> 
</head> 
<body> 

<div class="ui-widget"> 
    <label for="tags">Anshu: </label> 
    <input id="tags";> 
</div> 


</body> 
</html> 
+0

請接受它是否有效:) – anshuVersatile

相關問題