gpt4 book ai didi

javascript - JSP 中的预输入

转载 作者:行者123 更新时间:2023-11-28 04:54:23 26 4
gpt4 key购买 nike

在我的 JSP 中使用 typeahead 时,无法识别它。我尝试过不同的方式来导入文件,包括离线和在线。

<script src=js/typeahead.jquery.js></script>

or

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.2/bootstrap3-typeahead.js">

我的代码@Html

<div class="form-group">
<input class="typeahead" id="input-address" type="text" placeholder="Your Address">
</div>

我的代码@JavaScript

<script type="text/javascript">

$(document).ready(function(){
$("input-address").typeahead({
source: ['Washington', 'Sydney', 'Amsterdam', 'Beijing', 'Cairo']
, minLength:
});
});

即使按照建议完成,我也没有得到 typeahead 的结果。

我等着,谢谢!

最佳答案

这是一个最小的工作示例。您需要加载 Bootstrap 和 jQuery。您可以按类或 ID 选择输入元素。

<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<input id="input-address" type="text" placeholder="Your Address">
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/bootstrap-3-typeahead/4.0.2/bootstrap3-typeahead.js"/></script>
<script>
var $input = $("#input-address");
$input.typeahead({source: ['Washington', 'Sydney', 'Amsterdam', 'Beijing', 'Cairo']});
</script>
</body>
</html>

关于javascript - JSP 中的预输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42662171/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com