指定jQuery自动完成结果宽度

时间:2013-04-29 09:58:35

标签: jquery autocomplete

如何指定以下jQuery自动完成的结果宽度?

$( "#autocomplete" ).autocomplete({
    minLength: 2,   
    source: function( request, response ) {
        var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( request.term ), "i" );
        response( $.grep( tags, function( item ){
            return matcher.test( item );
        })
    }
});

谢谢!

1 个答案:

答案 0 :(得分:6)

$( "#autocomplete" ).autocomplete({
 open: function() { 
                // After menu has been opened, set width to 100px
                $('.ui-menu')
                    .width(100);
            } ,
minLength: 2,   
source: function( request, response ) {
var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( request.term ), "i" );
response( $.grep( tags, function( item ){
return matcher.test( item );
}) );
}