It's been some years since I have had to do DOM manipulation with CSS and vanilla JavaScript.
I have an input element some default css that is being added to its wrapping div and not the input element itself like so:
<div class="field animated-label text required"> <label class="control-label" for="answer">Answer</label> <input class="form-control" /> </div> So the default css for this input element is dictated by this selector:
.rds-form .animated-label { border: 2px solid #ccc; border-radius: 2px; color: #767676 display: block; min-height: 40px; position: relative; } However when the user clicks out of the input element not having typed anything in, this selector gets appended on to give a red error border around the input element:
.rds-form .field-group.error, .rds-form .field.text.error, .rds-form .field.select.error, .rds-form .field.textarea.error { border: 2px solid #cc2233; position: relative; } How would this be handled in JavaScript? I am assuming this is handled by some JavaScript logic.