JavaScript - jQuery Notes

1. The form of $(function () {...}) is the ready event handler of the document object.

The evolution is as follows: 1.1 - 1.3 more and more simplified

1.1

        $(document).on('ready', function () {
            $('#testForm).on('submit', function () {
                alert('submit!');
            });
        });

1.2

$(document).ready(function () {
    // on('submit', function)也可以简化:
    $('#testForm).submit(function () {
        alert('submit!');
    });
});

1.3

$(function () {
    // init...
});

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325294470&siteId=291194637