Speed up development with full-stack environments for every branch.

Learn More

Create an autocomplete input box with typeahead.js [jQuery and JavaScript]

Forked from How to use the jQuery $().ready function.

31056 Runs 94586 Views 50950 Copies


zarknight 7

published 4 years ago

  <meta charset="utf-8">
  <title>Create an autocomplete input box with typeahead.js</title>
  <!-- Bootstrap CSS Toolkit styles -->
  <link rel="stylesheet" href="css/bootstrap.min.css">
  <link rel="stylesheet" href="css/styles.css">

  <div class="container">
    <p class="example-description">Prefetches data, stores it in localStorage, and searches it on the client: </p>
    <input id="my-input" class="typeahead" type="text" placeholder="input a country name">

  <!-- Load jQuery and the typeahead JS files -->
  <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
  <script src="js/typeahead.min.js"></script>

  <script type="text/javascript">
    // Waiting for the DOM ready...

      // applied typeahead to the text input box
        name: 'countries',

        // data source
        prefetch: 'data/countries.json',

        // max item numbers list in the dropdown
        limit: 10

Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).