How to achieve autocomplete feature over HTML drop-down or select element?

后端 未结 5 862
悲&欢浪女
悲&欢浪女 2021-01-17 04:51

Hi I am trying to create auto completion functionality for a drop-down OR select html form element.

I need a functionality like once us

5条回答
  •  孤城傲影
    2021-01-17 05:31

    This can be achieved in a simple way. Reference from the following library https://jqueryui.com/autocomplete/

    Import the following headers using cdn links

    
    
    
    
    

    Load an array with the data

     
    

    Create an input feild

    Complete Code

     $( 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
        });
      } );
    
    
    
      
      
      jQuery UI Autocomplete - Default functionality
      
      
      
       
    
    
     
    

提交回复
热议问题