jQuery Select2: how to make readonly select


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;
} 

readonly select2

1 Comment

Leave a Reply