I am missing something here. Seems like an easy question. I have this:
<form>
<input type="text" name="name" id="name" class="form-control" placeholder="Name" required />
<input type="text" name="address" id="address" class="form-control" placeholder="Address" required />
...
</form>
I want this function to work:
$('#submit').click(function() {
var fields = $('.form-control');
_.each(fields, function(field) {
if( field.value == "" ) {
field.css("background","#FFB6B5");
}
});
});
I get undefined is not a function on the line:
field.css("background","#FFB6B5");
Is like the field is not an element. Why this is happening?
_.each? Any reason you're not using jQuery's$.each?