Question

In HTML, how to create and populate an autocomplete form jQuery UI?


Annonce
Ad

Answer

<html>
    <head>
        <!-- Import jQuery and jQuery UI (user Interface) -->
        <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
        <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
        <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
        
        <!-- Autocomplete script -->
        <script>
            $( function() {
                var availableTags = ['Alfa','Bravo','Charlie','Delta','Echo','Foxtrot','Golf',
                'Hotel','India','Juliett','Kilo','Lima','Mike','November','Oscar','Papa','Quebec',
                'Romeo','Sierra','Tango','Uniform','Victor','Whiskey','X-ray','Yankee','Zulu'];
                
                $( "#tags" ).autocomplete({
                    source: availableTags
                });
            });
      </script>
    </head>
    
    <body>
        <!-- Form with autocomplete -->
        <input id="tags">
    </body>
</html>


[source]
# ID Query