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

后端 未结 14 2257

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');
    
    0 讨论(0)
  • 2020-12-28 14:46

    Simply use the jQuery CSS method:

    css("width", "300px");
    

    http://api.jquery.com/css/#css2

    You can append this after adding your combobox.

    How do you use the combobox in your code?

    0 讨论(0)
提交回复
热议问题