Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript JqueryUI自动完成在焦点上返回错误的项_Javascript_Jquery_Jquery Ui - Fatal编程技术网

Javascript JqueryUI自动完成在焦点上返回错误的项

Javascript JqueryUI自动完成在焦点上返回错误的项,javascript,jquery,jquery-ui,Javascript,Jquery,Jquery Ui,我在这个项目上使用了JqueryUI,我正在工作。 当我用向下箭头键关注列表中的下一个项目时,jqueryui返回上一个选中的项目 这是Jquery代码 $( "#itemname" ).autocomplete({ source: function( request, response ) { var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( request.term ), "i" )


我在这个项目上使用了JqueryUI,我正在工作。
当我用向下箭头键关注列表中的下一个项目时,jqueryui返回上一个选中的项目

这是Jquery代码

$( "#itemname" ).autocomplete({
    source: function( request, response ) {
            var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( request.term ), "i" );
            response( $.grep( tags, function( item ){
                return matcher.test( item );
            }) );
        }, 
        //focus: function(event) { alert( event.type ); }
        focus : function(event, ui) { 
            //alert( $(this).val() );
            var item_name_this = $(this).val();
            $('#properties_item_name').html(item_name_this);               
        }
});

演示
-->

可能是由于基于零的索引导致
$(this).val()
出错。使用
ui.item.val
取而代之非常感谢,它工作起来很有魅力,我花了一天的时间试图解开这个谜团,这一切都是从如何启动
focus
事件开始的。你真让我高兴D}-
focus: function (event, ui) {
     var item_name_this = ui.item.value;
     $('#properties_item_name').html(item_name_this);
}