2015-07-01 43 views
0

我在JQuery中有自動完成的問題。這是我的autoComplete.html文件:文本字段出現在頁面上,但在輸入時不顯示提示。我究竟做錯了什麼?JQuery中的自動完成不顯示提示

編輯: 我已經修正@Praveen庫馬爾回答我的代碼,但仍TextBox不顯示提示。編號2: 問題在腳本鏈接。取而代之的

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"></link> 

應該有:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"></link> 

現在工作的很好。 現在我的代碼如下所示:

 <head> 
    <meta charset="utf-8"></meta> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"></meta> 
    <meta name="viewport" content="width=device-width, initial-scale=1"></meta> 
    <meta name="description" content=""></meta> 
    <meta name="author" content=""></meta> 

    <title>Gigs Map Inserting</title> 

    <!-- Bootstrap Core CSS --> 
    <link href="http:/css/bootstrap.min.css" rel="stylesheet"></link> 


    <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"></link> 
    <!-- Linki do skryptow --> 

    <script> 

    $(document).ready(function() { 
      var availableTags = [ 
      "FirstOption", 
      "SecondOption", 
      "ThirdOption" 
      ]; 
      $("#tags").autocomplete({ 
      source: availableTags 
      }); 
     }); 
    </script> 


    <script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script> 
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js" ></script> 



    </head> 
<body> 
<div th:class="form-group"> 
    <label class="col-md-3 control-label">Tags: </label> 
    <input class="form-control" id="tags" name="tags" /> 
</div> 

+0

你好,你在嗎? –

回答

1

變化包容的順序,更新了jQuery文件的引用:

<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script> 
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js" ></script> 

添加source

$("#tags").autocomplete({ 
    source: availableTags 
}); 

片段

$(document).ready(function() { 
 
    var availableTags = [ 
 
    "FirstOption", 
 
    "SecondOption", 
 
    "ThirdOption" 
 
    ]; 
 
    $("#tags").autocomplete({ 
 
    source: availableTags 
 
    }); 
 
});
@import url("//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css");
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script> 
 
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js" ></script> 
 

 
<div th:class="form-group"> 
 
    <label class="col-md-3 control-label">Tags: </label> 
 
    <input class="form-control" id="tags" name="tags" /> 
 
</div>