JS Basics-Get style without setting inline elements, timer

Source: Internet
Author: User
Tags setinterval

One, getComputedStyle (document.getElementById ("Div1"). width) is incompatible under ie6,7,8;

document.getElementById ("Div1"). Currentstyle.width is incompatible under standard browsers

Workaround: Attribute judgment

With the above two methods, the following questions should be noted:

    • Gets the computed style of the computer (browser)
    • Background:url () Red ... Compound style (do not get)
    • BackgroundColor single style (not to make judgments)
    • Do not have spaces
    • Do not get a style that is not set: incompatible

Second, the timer

    • SetTimeout ("function", time) sets a timeout object, in milliseconds
    • SetInterval ("function", time) sets a timeout object, in milliseconds
    • SetInterval is auto-repeating, settimeout does not repeat and executes only once.

    • Cleartimeout (object) clears the SetTimeout object that has been set
    • Clearinterval (object) clears the SetInterval object that has been set

Note that when setting the SetInterval, if the timer is controlled by the event, it is advisable to shut it down and avoid setting the timer problem more than once.

JS Basics-Get style without setting inline elements, timer

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.