I am appending content into a Div.
Now i want to change its background color when the div appends.
If the div is green by default, so when it appends, it should change the color to blue slowly and than again change back to its default color green.
Here is my Fiddle:
Here is what I have tried so far.Providing Code here:
Jquery:
$('#add').click(function (){
$('.main_container').append('<div class="container"> this is a Test</div>').animate({ "background-color": "blue" }, 900, "linear").delay().fadeIn(500).animate({ "background-color": "green" }, 900, "linear").delay().fadeIn(500);
});
HTML:
<div class="main_container" >
<div class="container"> this is a Test</div>
</div>
<a href="javascript:void(0);" id="add">Add</a>
CSS:
.container
{
width:400px;
background-color:green;
color:white;
margin:2px;
}
.main_container
{
width:400px;
}