Home >Web Front-end >JS Tutorial >jQuery.holdReady() method usage example_jquery

jQuery.holdReady() method usage example_jquery

WBOY
WBOYOriginal
2016-05-16 16:24:11987browse

The example in this article describes the usage of jQuery.holdReady() method. Share it with everyone for your reference. The specific analysis is as follows:

This method can pause or resume the jQuery.ready() event.
Calling this method can delay jQuery's ready event, which means that although the document has been loaded, the ready event handling method will not be executed.
The jQuery.holdReady() method can be called multiple times to delay jQuery's ready event. When certain conditions are met, the delay can be released one by one by setting the parameters of this method to false. This method is generally used for dynamic script loading. Once the script is loaded, you can then set the parameters of this method to false to release the delay on the jQuery.ready() event.

Grammar structure:

Copy code The code is as follows:
jQuery.holdReady(hold)

Parameter list:

参数 描述
hold 如果值为true,则会延迟jQuery.ready()事件。
如果值为false,则会解除对jQuery.ready()事件延迟。

If the value is false, the delay on the jQuery.ready() event will be released.

Example code:

Example 1:

Copy code The code is as follows:






Script Home







In the above code, due to the addition of jQuery.holdReady(true), the function in ready() will not be executed even though the document is loaded.
Example 2:

Copy code The code is as follows:






Script Home








After clicking to release the delay, it will pop up.

I hope this article will be helpful to everyone’s jQuery programming.

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