Principle and Implementation Code for implementing div flash in js

Source: Internet
Author: User

I recently learned how to use easyui and found that the framework is easy to use and concise. I can make it easy to get this framework ....

Today, this application can be said to be speechless to me. I can understand the source code at a glance, but I still feel amazing before. I often tell myself that I need to use more brains, in fact, some of them did think about it, but it is really far-fetched, and when the source code is taken out, it is very clear, if at this time I can see my own expression, it is almost a tangle. If we say that quantitative change leads to qualitative changes, there will be too much difference in my quantity. I can't even be knowledgeable. How can I talk about creation.

Let's take a look at the implementation principles. What is the principle of flickering? In fact, it's just that display is frequently alternating between none and block. do you understand this.

Check the code first:

Html section:

<Div style = "width: 50px; height: 50px; background-color: cyan; display: block; "id =" showZone "> </div> // are you familiar with javascript? Part: window. onload = function () {var obj = document. getElementById ("showZone"); var timer = null; obj. onclick = function () {var I = 0; clearInterval (timer); timer = setInterval (function () {obj. style. display = I ++ % 2? "None": "block"; // There are still gains. This method is better than if .. else should have been much simpler. I> 8 & clearInterval (timer); // classic I> for short circuit}, 80 );};};

Although the principle is simple, the code of the predecessors is much simpler than the code I wrote, and it is still very rewarding.

Easyui is also on the learning agenda. The sky is full every day .....

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.