SnazzyGill
SnazzyGill

Reputation: 13

want to fade in and fadeout the background color in webpage?

Javascript Jquery code

want to fade in and fade out the background color on div

    $("div").focusin(function(){
        $(this).css("background-color","green"),fadein(5000);
    });
    $("div").focusout(function(){
        $(this).css("background-color","white"),fadein(5000);
    });

})

HTMl code

<div>
  first name:
  <input type="text" name="" id="" />
  last name:
  <input type="text" name="" id="" />
</div>

Upvotes: 1

Views: 95

Answers (1)

vanowm
vanowm

Reputation: 10221

Unless you specifically want to do it with jquery, there is an easy css-only method:

input
{
  transition: background-color 5s ease;
  background-color: white;
}
input:focus
{
  background-color: green;
}
<div>
  first name:
  <input type="text" name="" id="">
  last name:
  <input type="text" name="" id="">
</div>

Upvotes: 1

Related Questions