总有人间一两风,填我十万八千梦

jQuery .ready 用法 手册 | 示例代码

jQuery开发手册 归档 349℃ 0评论

Description: A Promise-like object (or "thenable") that resolves when the document is ready.

  • version added: 1.8jQuery.ready

As of jQuery 3.0, use of this object is supported via jQuery.when or the native Promise.resolve(). Code should not make assumptions about whether this object is a jQuery.Deferred, native Promise, or some other type of promise object.

See also ready(), which makes use of this.

Examples:

Listen for document ready using jQuery.when.

1
2
3
$.when( $.ready ).then(function() {
// Document is ready.
});

Typical usage involving another promise, using jQuery.when.

1
2
3
4
5
6
7
$.when(
$.getJSON( "ajax/test.json" ),
$.ready
).done(function( data ) {
// Document is ready.
// Value of test.json is passed as `data`.
});

转载请注明:悠然品鉴 » jQuery .ready 用法 手册 | 示例代码

喜欢 (0)or分享 (0)
发表我的评论
取消评论

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址