I want the text not to be lost, only the red background color should be lost. Here my code:
$('#confirmacion').fadeIn(9500);
$('#confirmacion').fadeOut(9500);
#confirmacion{
background-color: red;
color: #000;
height: 2em;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="confirmacion"> iniciando un nuevo registro.</div>
Greeting!
As we well know, the fadeIn and fadeout action is applied on the element and its "children", therefore making one of them visible beyond the visibility of the parent element is somewhat difficult.
There is a solution, from the same jquery library there is the animate() method with this method, you can do what you need, specifying a time for it to run, therefore the solution that I would provide would be this:
What we do in this is call the jQuery Color library to allow us to dynamically change the div's backgroundColor and animate it in the process.
More information .animate()
I hope it helps you.
What you are trying to do is not going to work because you are vanishing
<div>
him and with him everything that he carries inside.Here I leave you an alternative that could help you (I set it to do the animation when you click so that the example is more comfortable):