2021年1月19日星期二

I want to change the font-family of the "Hello World" every second using javascript

It is changing the font family only one time while it should change the font family every second. please let me know what is the problem and why its not working.Thanks!

</head>  <body>      <h1 id="js_world">Hello World</h1>      <script>          window.onload = function(){            var x = document.getElementById("js_world");          x.style.fontFamily = "helvetica";            function changeFontFamily(){              if (x.style.fontFamily === "helvetica"){                  x.style.fontFamily = "times new roman";                 }              else if (x.style.fontFamily === "times new roman"){                  x.style.fontFamily = "sans-serif";                  }else if(x.style.fontFamily === "sans-serif"){                        x.style.fontFamily = "helvetica"                        }           };         window.setInterval(changeFontFamily,1000);       }       </script>  </body>  
https://stackoverflow.com/questions/65802416/i-want-to-change-the-font-family-of-the-hello-world-every-second-using-javascr January 20, 2021 at 10:52AM

没有评论:

发表评论