Based on your other post that got deleted, I think this is what you're after:
$(document).ready(function () {
$('#e1').select2();
$('#e2').select2().on('change', function(){
$(this).next().find('.select2-selection').css({
backgroundColor: this.value
});
}).trigger('change');
});
Just listen for the change event and update the CSS then.
Here's an updated fiddle from your other post: https://jsfiddle.net/jmarikle/ea7q41k7/