4

I Have problem with focus input in jQueryUI. I used hover() method on button and it's working, but focus() on input doesn't work. I don't have idea why. Here's code and fiddle

$(document).ready(function(){
  $('input[type=text]').focus(function(){
    $(this).stop().animate({
      backgroundColor: '#000'
    }, 1000);
  }, function() {
    $(this).stop.animate({
      backgroundColor: 'rgba(0,0,0,0)'
    }, 1000); 
  });
});

And here's fiddle

https://jsfiddle.net/ssa7sh4f/12/

falauthy
  • 521
  • 1
  • 5
  • 15

1 Answers1

1

I don't know exactly what you're trying to do. But in your code you're assigning 2 handlers to focus (like @squint pointed out).

Instead, you can assign one handler to focus() and one to focusout(), like this:

$(document).ready(function(){
  $('input[type=text]').focus(function(){
    $(this).css('background-color', 'black');
  }).focusout(function() {
    $(this).css('background-color', 'white');
  });
});

https://jsfiddle.net/g6997gnh/