Argoron Argoron - 4 months ago 22
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):

<form>
<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" />
</form>


jQuery

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

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


Thanks

Answer

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