我有一个HTML
<script type="text/javascript">
var colors = ["red", "blue", "green", "yellow", "brown", "black"];
$('#vahid').typeahead({source: colors});
</script>
<input type="text" id="vahid" data-provide='typeahead'>
但是typeahead没有任何建议。我的页面没有错误!
答案 0 :(得分:1)
您在不存在的元素上执行typeahead尝试
<script type="text/javascript">
$(document).ready(function() {
var colors = ["red", "blue", "green", "yellow", "brown", "black"];
$('#vahid').typeahead({source: colors});
})
</script>
<input type="text" id="vahid" data-provide='typeahead'>
现在代码将在下载所有dom元素后执行