gpt4 book ai didi

javascript - jQueryUI 自动完成下拉列表缺少格式

转载 作者:行者123 更新时间:2023-11-30 14:41:37 25 4
gpt4 key购买 nike

我正在尝试让 jQueryUI 自动完成功能在本地测试页中运行。

在他们的演示页面上看起来不错: https://jqueryui.com/autocomplete/#remote

然而,当我在本地运行它时,使用完全相同的演示代码(删除了远程调用)它工作正常,除了不显示下拉框,只是一个带有丑陋的默认黑色 li 项目符号的丑陋列表:

ugly formatting

因此,该页面上的代码之外有一些东西将 ul 格式化为更清晰的下拉菜单。我没看到。我可能可以在几分钟内自行设置样式,但我宁愿让它正常工作。

这是他们的演示代码,经过调整以在本地针对数组运行:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Autocomplete - Remote datasource</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="https://jqueryui.com/resources/demos/style.css">
<style>
.ui-autocomplete-loading {
background: white url("images/ui-anim_basic_16x16.gif") right center no-repeat;
}
</style>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
function log( message ) {
$( "<div>" ).text( message ).prependTo( "#log" );
$( "#log" ).scrollTop( 0 );
}

$( "#birds" ).autocomplete({
source: ["abc","def"],
minLength: 2,
select: function( event, ui ) {
log( "Selected: " + ui.item.value + " aka " + ui.item.id );
}
});
} );
</script>
</head>
<body>

<div class="ui-widget">
<label for="birds">Birds: </label>
<input id="birds">
</div>

<div class="ui-widget" style="margin-top:2em; font-family:Arial">
Result:
<div id="log" style="height: 200px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
</div>


</body>
</html>

最佳答案

这不是您源代码中的问题,但是当您忘记在标题中添加 jquery 样式表时也会发生这种情况:

<link rel="stylesheet" ref="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">

这可能对其他人有帮助。

关于javascript - jQueryUI 自动完成下拉列表缺少格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49565801/

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