Good evening,
currently I'm working on a form which has a few Select2 dropdowns. The whole project is developted in CodeIgniter. Now I want to change the border color of the first Select2 if any CodeIgniter form errors are present, but somehow it doesn't work.
This doesn't work:
<?php if (validation_errors()) : ?>
<script>
$('.select2:first').css('border-bottom', '1px solid red');
</script>
<?php endif; ?>
This doesn't work:
<?php if (validation_errors()) : ?>
<script>
$(document).ready(function() {
$('.select2:first').css('border-bottom', '1px solid red');
});
</script>
<?php endif; ?>
This doesn't work:
<?php if (validation_errors()) : ?>
<script>
$(function() {
$('.select2:first').css('border-bottom', '1px solid red');
});
</script>
<?php endif; ?>
Now, the funny thing is, if I execute $('.select2:first').css('border-bottom', '1px solid red'); in console it does change the color of the correct Select2. And if I put a alert("Somthing"); I get the alert window displayed, but it never changes the color.
Does anyone has an idea how I can solve this?