Home >Web Front-end >JS Tutorial >How to implement automatic loading of jquery

How to implement automatic loading of jquery

coldplay.xixi
coldplay.xixiOriginal
2020-11-27 10:11:213627browse

Method to implement automatic loading of jquery: First introduce the jquery library into the execution environment and test the operation of "data loading is completed and execution"; then test "execute after opening, regardless of whether the data is loaded or not".

How to implement automatic loading of jquery

The operating environment of this tutorial: Windows 7 system, jquery version 3.2.1. This method is suitable for all brands of computers.

Methods to implement automatic loading of jquery:

1. First, introduce the jquery library into the execution environment. The example is a jquery file that the author saved on the cdn.

How to implement automatic loading of jquery

2. Automatic loading is divided into:

  • Data loading is completed and executed

  • Execute as soon as it is opened, regardless of whether the data is loaded or not

How to implement automatic loading of jquery

3. First test the operation of "data loading completed and executed". The method code is as follows

window.onload=function(){
           testFunc();}

How to implement automatic loading of jquery

4. The running result is as shown in the figure. The function is automatically loaded successfully and the function result is output.

How to implement automatic loading of jquery

#5. Continue to test "execute as soon as it is opened, regardless of whether the data is loaded or not". The method code is as follows:

Method 1

$(document).ready(function(){    testFunc();});

Method 2

$(function(){    testFunc();});

How to implement automatic loading of jquery

6. The execution results are the same as the above methods, and they are all automatically load.

How to implement automatic loading of jquery

Related free learning recommendations: javascript (video)

The above is the detailed content of How to implement automatic loading of jquery. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more