How to add class to select2 element in v4.0

后端 未结 5 1620
故里飘歌
故里飘歌 2021-02-12 04:04

This is very similar to this question on how to add class to select2 element, however the answers there appear to target earlier versions of the framework which has undergone so

5条回答
  •  日久生厌
    2021-02-12 04:48

    We're using a React wrapper for Select2, so none of the current answers worked for us. However, we were able to make CSS that targeted the container even though we could not add a class to it by adding the class to the base element, then using an adjacent CSS selector:

    $('.select2').select2();
    .wrap + .select2-container .select2-selection--single {
        border: solid 1px #F00;
    }
    
    
    
    
    

提交回复
热议问题