Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is this Jquery code not working

Tags:

jquery

input

I want to change the CSS of an input field over a time of 1800 milisec. It works, but there is no smooth transition. Do I have to put a fadeIn/Out somewhere? What am I missing here:

$(".div-input").blur(function () {
     $('.div-input').removeClass("div-input", 1800).addClass('div-input-second');
});
like image 901
Youss Avatar asked Mar 18 '26 21:03

Youss


2 Answers

You can use .animate() to change the CSS values yourself, but there isn't a way to fade between classes like that.

like image 195
Jason Kaczmarsky Avatar answered Mar 20 '26 12:03

Jason Kaczmarsky


Looks like invalid parameters for one, and also you can use contextual this for the selector in your function for blur.

removeClass() takes either a class name or a function. Not sure what the 1800 in your parameter list. If you want animation look into animate.

Try this...

$(".div-input").blur(function () {
     $(this).removeClass("div-input").addClass('div-input-second');
});
like image 27
Gabe Avatar answered Mar 20 '26 12:03

Gabe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!