1

It's been a while since I coded with jQuery so I'm probably making a basic error. Can anyone advise where I am going wrong please? Nothing happens when I type in the search box. Thanks.

In the head section:

<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<!-- JS file -->
<script src="search/jquery.easy-autocomplete.min.js"></script> 

<!-- CSS file -->
<link rel="stylesheet" href="search/easy-autocomplete.min.css"> 

<script>
    var options = {
        data: ["blue", "green", "pink", "red", "yellow"]
    };

    $("#basics").easyAutocomplete(options);
</script>

In the body section:

<div class="container">
    <ul class="breadcrumb">
        <li>You are here:</li>
        <li><a href="index.php">Home</a></li>
        <li><a href="#">Search</a></li>
        <li><a href="#">Example</a></li>
    </ul>
    <h2>Search</h2>
    <input id="basics" />
</div>
executable
  • 3,365
  • 6
  • 24
  • 52
Emily
  • 97
  • 1
  • 12

1 Answers1

1

Your code is fine. It appears only your library links where no good.

This example uses jQuery 2.1.1 and easy-autocomplete 1.3.5

ENJOY

var options = {
  data: ["blue", "green", "pink", "red", "yellow"]
};

$("#basics").easyAutocomplete(options);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/easy-autocomplete/1.3.5/jquery.easy-autocomplete.js"></script>

<div class="container">
  <p>Search for a colour</p>
  <input id="basics" />
</div>
DreamTeK
  • 32,537
  • 27
  • 112
  • 171
  • I've tried that and it's still not working, even though the "run code snippet" here works. Can I just double check where I should be putting each snippet of code and how I should be running the webpage - i.e. I just need to open inside a browser? – Emily Oct 05 '18 at 09:31
  • @Emily check the path to your source script is accessible online. The path here inidicates it is stored locally on your machine. `search/jquery.easy-autocomplete.min.js` So online it should be accessible via `http://yoursite/search/jquery.easy-autocomplete.min.js` or just use the cdn link I used in my answer. – DreamTeK Oct 05 '18 at 11:20