Simple, you only use CSS:
select[readonly].select2 + .select2-container { pointer-events: none; touch-action: none; }
Online demo: https://jsfiddle.net/sans_amour/hz1qyjL4/
You can specify the background color of readonly select:
select[readonly]+.select2-container .select2-selection--single{ background-color: #e9ecef; }
1 Comment
jQuery Select2: how to disable or enable select | Free Online Tutorials
(December 31, 2019 - 2:53 pm)[…] Related: jQuery Select2: how to make readonly select […]