Create simple devouring special effects based on replaceChild _ javascript tips-js tutorial

Source: Internet
Author: User
This article uses JavaScript and css to achieve simple devouring effect, and the code is easy to understand. If you need it, you can refer to the demo image of this article:

View Source Code

[HTML code description]

 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

[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 a li element var oAdd = document. createElement ('lil'); // you can specify the css style oAdd for the newly added element. className = "in" Export oadd.style.css Text = 'background-color: red; border-radius: 100'; // replace 50% lisetTimeout (function () {oList. replaceChild (oAdd, document. getElementsByTagName ('lil') [0]); // after 1 s, run the incrementNumber function setTimeout (incrementNumber, 1000);}, 1000); function incrementNumber () {// obtain the 1st li var oLi1 = document in the oList. getElementsByTagName ('lil') [1]; // if yes, replace if (oLi1) {oList. replaceChild (oAdd, oLi1); setTimeout (incrementNumber, 1000);} script

The above content will share with you the simple Effect of devouring Based on replaceChild. I hope you will like it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.