繁体   English   中英

jquery ui自动完成结果框位于左上角

[英]jquery ui an auto completion result box is on top left corner

我是jquery的初学者,我正在我的应用程序中实现jquery ui自动完成。 但是当我练习它的例子时,自动填充的结果框出现在左上角。 我尝试了所有可能的方法将它放在文本框中,但没有运气。 请指导我,下面是代码片段:

<html>
<head>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src ="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>

<script type="text/javascript">
    $(document).ready(function(){
        console.log("here");
        var keyList=[{value:"chinese" },
                     {value:"biryani"},
                     {value:"kabab" },
                     {value:"pizza"},
                     {value:"burger"},
                    ];
        $('#keyword').autocomplete({
                source: keyList,
                select: function(event, ui){
                        //$("#sugg-tag").val(ui.item.empUserRole);
                        console.log('select - '+ui.item.value);

                    }
            });

    });
</script>

</head>

<body>

Search keyword <input type="text" id="keyword">

</body>

</html> 

我用最新的jquery ui检查了你的代码,它运行正常。 我已经用版本“1.12.0”更新了jquery ui。 请查看下面的代码段。

  $(document).ready(function(){ var keyList=[{value:"chinese" }, {value:"biryani"}, {value:"kabab" }, {value:"pizza"}, {value:"burger"}, ]; $('#keyword').autocomplete({ source: keyList, select: function(event, ui){ console.log('select - '+ui.item.value); } }); }); 
 <link rel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css"> <script src ="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script> <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script> Search keyword <input type="text" id="keyword"> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM