'jquery select 2 change dropdown width dynamically
I'm using jquery select 2 and need to reduce width of dropdown dynamically.
This is my code,
$('.myselect').select2();
$('.myselect').on('select2:open', function(e) {
var width = $('.select2-dropdown').width();
width -= 20;
$('.select2-dropdown').attr('style', 'width: '+width+'px !important');
});
What I need to do is reduce width of dropdown by 20px. But tis code not working
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
