JS Knowledge Point Collection

Source: Internet
Author: User

  1. SetInterval

    The SetInterval () method invokes a function or evaluates an expression according to the specified period (in milliseconds).
    The SetInterval () method keeps calling functions until Clearinterval () is called or the window is closed. The return value of SetInterval () returns
    A parameter that can be passed to the Window.clearinterval () to cancel the periodic execution of the value of code.
    <body>
    <input type= "text" id= "clock" size= "/>"
    <script language=javascript>
    var int=self.setinterval ("Clock ()", 50)
    function Clock ()
    {
    var t=new Date ()
    document.getElementById ("Clock"). value=t
    }
    </script>
    </form>
    <button onclick= "int=window.clearinterval (int)" >stop interval</button>
    </body>

  2. jquery animation effects animate and ScrollTop use instances together

    Animate is a special effect function method of JQ, and the Animate () method performs a custom animation of the CSS property set. This method changes the element from one state to another through CSS styles.
    CSS property values are changed gradually so that you can create animation effects.
    Only numeric values can create animations (such as "margin:30px").
    String values cannot create animations (such as "background-color:red").
    $ (' #shang '). Click (function () {$ (' html,body '). Animate ({scrolltop: ' 0px '}, 800);});
    The above code indicates that the scroll bar jumps to 0, and the page movement speed is 800.
    Practical examples of combining scrolltop:
    JQuery (document). Ready (function ($) {
    $ (' #shang '). Click (function () {
    $ (' html,body '). Animate ({scrolltop: ' 0px '}, 800);
    });
    $ (' #comt '). Click (function () {
    $ (' html,body '). Animate ({scrolltop:$ (' #comments '). Offset (). Top}, 800);
    });
    $ (' #xia '). Click (function () {
    $ (' html,body '). Animate ({scrolltop:$ (' #footer '). Offset (). Top}, 800);
    });
    });
    Indicates that the click Correlation ID is moved to the specified location:
    Click on the element with ID Shang and go back to the top;
    Click on the element with ID COMT and return to the location with ID comments;
    Click on the element with ID Xia, back to the bottom;

    $ ('. Chat-content '). Animate ({
    ScrollTop: $ ('. Chat-content ') [0].scrollheight}, 500
    );//The content of this implementation chat-content is constantly increasing, the scroll bar rolls down

  3. Get time

    var d = new Date ();
    var send_time = d.gethours () + ":" + d.getminutes () + ":" + d.getseconds ();

  4. Json

    Json.parse ()

  5. Monitor whether a key is pressed to perform a special method

JS Knowledge Point Collection

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.