Typeahead search

runningcoder typeahead

by Ilias Trichopoulos

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdn.rawgit.com/running-coder/jquery-typeahead/develop/src/jquery.typeahead.css">
<script src="https://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="https://cdn.rawgit.com/running-coder/jquery-typeahead/develop/src/jquery.typeahead.js"></script>
<form id="form-country_v1" name="form-country_v1">
    <div class="i-location-field" id="location_data-wrapper">
        <div class="wrapper">
            <div class="typeahead__container venue-container">
                <div class="typeahead__field">
                    <span class="typeahead__query">
                        <input id="location-venue-location_data" class="i-location-input-field" type="text" placeholder="Venue" autocomplete="off">
                    </span>
                </div>
            </div>
        </div>
    </div>
</form>

JavaScript

$.typeahead({
    input: '#location-venue-location_data',
    minLength: 0,
    searchOnFocus: true,
    source: {data: ["Afghanistan", "Albania", "Algeria", "Andorra"]}
});