I do not know exactly what you are trying to do. But in your code, you assign 2 handlers to focus (for example, @squint pointed out).
Instead, you can assign one handler focus()and one for focusout(), for example:
$(document).ready(function(){
$('input[type=text]').focus(function(){
$(this).css('background-color', 'black');
}).focusout(function() {
$(this).css('background-color', 'white');
});
});
https://jsfiddle.net/g6997gnh/
source
share