So I have a random quote generator and every time the user clicks New Quote button, the background of body and mainDiv that contains the quote changes. I want a animation to take place, i want it so that it fades out and the new background fades in over 100ms. i did some reading but my case is different since my background is randomly choosen from an array with math.random. here's my code.
<body>
<div id="mainDiv" class="colorChange">
<button id="newQuote" class="btn btn-danger">New Quote</button>
<div id="targetP"></div>
</div>
</body>
var divBackground, bodyBackground,quoteButton,targetP,number,sec;
targetP=$("#targetP").val();
$("#newQuote").click(function () {
number=Math.floor((Math.random() * 10) + 1);
sec=Math.floor((Math.random() * 10) + 1);
$("#mainDiv").css("background-color",colors[number]);
$("body").css("background-color",colors[sec]);
$("#targetP").html(quotes[number]);
});
how do i animate change of background color (body and main div) so the previous background fades out in 100ms and new one comes in at 100ms? thanks