Effect Demo Chart:
Source view
"HTML code description"
<ul class= "list" id= "list" >
<li class= "in" >1</li>
<li class= "in" >2</li>
<li class= ' in ' >3</li>
<li class= ' in ' >4</li>
<li class= ' in ' >5</li>
<li class= "in" >6</li>
</ul>
"CSS Code description"
. in{
height:20px;
line-height:20px;
width:20px;
Background-color:blue;
Text-align:center;
Color:white;
}
"JS Code description"
<script>
var olist = document.getElementById (' list ');
Add an LI element
var oadd = document.createelement (' li ');
Sets the CSS style for the new element
oadd.classname = "in";
OAdd.style.cssText = ' background-color:red;border-radius:50% ';
1s oadd replaces No. 0 li
settimeout (function () {
olist.replacechild (oadd,document.getelementsbytagname (' li ') [0] );
1s after the execution of Incrementnumber function
settimeout (incrementnumber,1000);
},1000);
function Incrementnumber () {
//Get olist 1th li
var oLi1 = document.getelementsbytagname (' li ') [1];
If present, replace the process
if (oLi1) {
olist.replacechild (oadd,oli1);
SetTimeout (incrementnumber,1000);
}
</script>
The above content for everyone to share based on the replacechild production of simple phagocytosis effects, I hope you like.