我想使用一個名爲predictiveSearch
對預先輸入功能的插件,但我得到的錯誤:
TypeError: $(...).predictiveSearch is not a function
我試圖重新訂購腳本的加載,但仍然無法正常工作。有人可以請幫助。這是代碼。
<head>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="../js/bootstrap.min.js" type="text/javascript"></script>
<script src="../js/predictiveSearch.js" type="text/javascript"></script>
<script src="../js/jquery.predictive-search.js" type="text/javascript"></script>
</head>
<body>
<form class="navbar-form navbar-right" role="search" method="post" action="">
<input type="text" placeholder="Search" class="form-control predictive-search" autocomplete="off" data-module="predictive-search" data-url="../json/predictiveSearchResults.json">
<!-- form elements... -->
</form>
</body>
predictiveSearch.js包含以下代碼:
$(function(){
$('[data-module="predictive-search"]').predictiveSearch();
});
http://stackoverflow.com/questions/12343714/typeerror-is-not-a-function-when-calling-jquery-function – user3800243