Autocomplete Without jQuery UI

后端 未结 8 943
野性不改
野性不改 2021-02-04 01:52

I\'m using jQuery in my project and I need to implement autocomplete, but I\'d like to avoid including jQuery UI widget, and hopefully use some specific external plugin. Could y

相关标签:
8条回答
  • 2021-02-04 02:26

    Try this, this will be help you

    HTML

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

    JS

    $(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
        });
      });
    

    Fiddle here

    0 讨论(0)
  • 2021-02-04 02:28

    No need to include JQuery or any other third party library.

    IP_autoComplete function will automatically concatinate field value to URL (1st parameter). For example textbox has value neeraj then arrjson.php?Name=neeraj will be triggered.

    You can use IP_autocomplete function for static value as well. Just add # sign once at starting in your string (comma sepreated). E.g: "#val1,val2,val3"

    arrjson.php should return json encoded string.

    HTML:

    <script type="text/javascript" src="http://services.iperfect.net/js/IP_generalLib.js">
    

    Body

    <input type="text" name="testautocomplete" id="testautocomplete" onkeypress="IP_autoComplete('arrjson.php?Name=',this.id,event)">
    

    JSFiddle

    Or simply you can give static:

    <input type="text" name="testneeraj" id="testneeraj" onkeyup="IP_autoComplete('#sachin bhalake,ishwar agam,mohsin khan,neeraj dhekale,sheetal dhekale,ajay bhalake',this.id,event)">
    
    0 讨论(0)
提交回复
热议问题