javascript fade color

Solutions on MaxInterview for javascript fade color by the best coders in the world

showing results for - "javascript fade color"
Chenai
18 Nov 2020
1<div id="x" style="background-color:rgb(255,255,105)">hello world</div>
2<script type="text/javascript">
3var gEvent=setInterval("toWhite();", 100);
4function toWhite(){
5    var obj=document.getElementById("x");
6    var unBlue=10+parseInt(obj.style.backgroundColor.split(",")[2].replace(/\D/g,""));
7    if(unBlue>245) unBlue=255;
8    if(unBlue<256) obj.style.backgroundColor="rgb(255,255,"+unBlue+")";
9    else clearInterval(gEvent)
10}
11</script>