Is it possible to set the width of a jQuery autocomplete combobox?

后端 未结 14 2297

I am using this jQuery UI combobox autocomplete control out of the box off the jQuery UI website:

My issue is that I have multiple comboboxes on a page, and I want t

14条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-28 14:46

    JavaScript

    var $myinput = $('#myinput').autocomplete({source: ['ABC', 'BCD', 'CDE']})
    $myinput.data('autocomplete').menu.element.addClass('myautocomplete');
    

    CSS

    .myautocomplete{width:300px!important;}
    

    You can't set the width directly, because it will get overwritten. But you can set the min-width directly.

    var $myinput = $('#myinput').autocomplete({source: ['ABC', 'BCD', 'CDE']})
    $myinput.data('autocomplete').menu.element.css('min-width', '300px');
    

提交回复
热议问题