0

So this is how to set the color with Css:
.select2-container--default .select2-selection--single .select2selection__placeholder {color: #444;}

But how can i change the color with Jquery using "this"?

$(this).css('color', 'red') Don't work.
$(this)[0].css('color', 'red') Don't work.
$(this[0]).css('color', 'red') Don't work.

EDIT
console.log( $this) )
0:select#employment.form-control.select2.req_place

Björn C
  • 3,094
  • 6
  • 33
  • 71

2 Answers2

2

Since your $(this) shows that it is a select element. You need to find its sibling .select2-container which is what is shown on the UI. And within this sibling find .select2-selection__placeholder and change its color.

So use this code.

$(this).siblings('.select2-container').find('.select2-selection__placeholder').css('color', 'red');
Rajshekar Reddy
  • 17,202
  • 3
  • 34
  • 54
2

You can also use this:

.select2-search__field::placeholder{
    color: #cecfd0;
}
.select2-search__field:-ms-input-placeholder {
    color: #cecfd0;
}
.select2-search__field::-ms-input-placeholder {
    color: #cecfd0;
}