Argoron Argoron - 1 year ago 74
Javascript Question

jquery background-color change on focus and blur

I have the following problem: I have a form with three text input fields, and I want to change the background-color when one of the fields has focus, and get it set back when it loses focus. I have come up with the following code:

HTML (simplified):

<input class="calc_input" type="text" name="start_date" id="start_date" />
<input class="calc_input" type="text" name="end_date" id="end_date" />
<input class="calc_input" size="8" type="text" name="leap_year" id="leap_year" />


$(document).ready(function() {
$(this).css({'background-color' : '#FFFFEEE'});

$(this).css({'background-color' : '#DFD8D1'});


Answer Source

#FFFFEEE is not a correct color code. Try with #FFFFEE instead.