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
Even easier, just CSS can resolve the problem:
#FFFFEEE
is not a correct color code. Try with#FFFFEE
instead.in code there should be coma"," not colon ":"
the code must be
$(this).css({'background-color' , '#FFFFEE'});
i hope it helps.
regards Saleha
What you are trying to do can be simplified down to this.
Tested Code:
Complete:
Tested in version:
jquery-1.9.1.js
jquery-ui-1.10.3.js