Try using the code below.
You can set the maximum width as you want in css.
JavaScript:
$('#yourXYZID').multiselect({
buttonText: function(options)
{
var retStr = "";
if (options.length === 0) {
retStr = "None selected";
} else if(options.length <=3){
var textArray = [];
$.each(options,function(key,value){
textArray.push($.trim($(value).html()));
});
retStr = "<div class='pull-left restricted'>"+textArray.join(",")+"</div>";
} else {
retStr = options.length+" selected";
}
return retStr+" <b class='caret'></b>";
}
});
CSS
.multiselect.dropdown-toggle.btn.btn-default > div.restricted {
margin-right: 5px;
max-width: 100px;
overflow: hidden;
}
source
share