Home >Web Front-end >JS Tutorial >js method to achieve text flashing effect_javascript skills

js method to achieve text flashing effect_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:25:261647browse

The example in this article describes the code for realizing provincial and municipal linkage special effects based on jquery. It is shared with everyone for your reference. The details are as follows:

Operation rendering:

Implementation principle: Use the style object to set css attributes, and combine it with the timer to implement js to achieve text flashing effects.

The specific code is as follows

<html>
 <head>
 <meta charset="gb2312" />
 <title>js实现文字闪烁特效</title>
 </head>
<script>
 var flag = 0;
 function start(){
 var text = document.getElementById("myDiv");
 if (!flag)
 {
 text.style.color = "red";
 text.style.background = "#0000ff";
 flag = 1;
 }else{
 text.style.color = "";
 text.style.background = "";
 flag = 0;
 }
 setTimeout("start()",500);
 }
</script>
 <body onload="start()">
 <span id="myDiv">css的世界是如此的精彩!</span>
 </body>
</html>

Copy the code and it will run.

I hope this article will be helpful to everyone in JavaScript programming.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn