I am using select2 for displaying a multiple selection component. Instead of showing the close icon(x) to the left of the item, how can I move it to the right of the selected item?
Your best option is to use the placeholder support in Select2 and include a blank option tag as your default selection.
Select2 gives you a customizable select box with support for searching, tagging, remote data sets, infinite scrolling, and many other highly used options.
If you add float: right;
to the .select2-selection__choice__remove
css class, this will set it on the right side.
EDIT: If you don't want to touch the select2 stylesheets, you can always use jquery and do something like this:
$('.select2').on('select2:open', function () {
$('.select2-selection__choice__remove').addClass('select2-remove-right');
});
.select2-remove-right {
float: right;
}
.select2-selection__choice__remove {
float: right;
margin-left: 5px /* I added to separate a little bit */
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With