记录小问题“在使用模态框中使用 jquery-ui autocomplete,无法显示下拉框的数据”

jquery-ui autocomplete在模态框(model)中,出不来

知识点:在使用模态框中使用 jquery-ui autocomplete,无法显示下拉框的数据

参考博客:https://www.jianshu.com/p/3944693773ed

解决办法:在autocomplete中添加 appendTo

<body>
<html>

<div class="modal-body">

<form class="m-form m-form--fit m-form--label-align-right"  id="m-form-1">
    <label class="col-form-label col-lg-2 col-sm-12">
         药品名称 <span style="color: #F00">*</span>
   </label>
   <input type="text" style="width: 120px; z-index: 1055;"  οnchange="test1(this)"
   class="form-control m-input" placeholder="药品名称" id="rolename" autocomplete="off" >
</form>

</div>

<script>
function test1(){
    debugger
    var arr=["zhansan","lishi"];
    $("#rolename").autocomplete({
        source : arr,// 数据
        appendTo:$("#m-form-1") //m-form-1是from表单的id

    });

}
</script>
</body>
</html>

版权声明:本文为weixin_38710952原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。