jQuery ready() 方法

jQuery 教程 · 2019-03-26 21:14:34

实例

使用 ready() 来使函数在文档加载后是可用的:

$(document).ready(function(){
    $("button").click(function(){
        $("p").slideToggle();
    });
});

定义和用法

当 DOM(document object model 文档对象模型)加载完毕且页面完全加载(包括图像)时发生 ready 事件。

由于该事件在文档就绪后发生,因此把所有其他的 jQuery 事件和函数置于该事件中是非常好的做法。如上面的实例所示。

ready() 方法规定当 ready 事件发生时执行的代码。

提示:ready() 方法不应该与 <body onload=""> 一起使用。

语法

允许使用以下两种语法:

$(document).ready(function)

ready() 方法只能用于当前文档,因此无需选择器:

$(function)

参数 描述
function 必需。规定当文档加载后要运行的函数。

点击查看所有 jQuery 教程 文章: https://codercto.com/courses/l/35.html

查看所有标签

Flexible Pattern Matching in Strings

Flexible Pattern Matching in Strings

Gonzalo Navarro、Mathieu Raffinot / Cambridge University Press / 2007-7-30 / USD 64.99

String matching problems range from the relatively simple task of searching a single text for a string of characters to searching a database for approximate occurrences of a complex pattern. Recent ye......一起来看看 《Flexible Pattern Matching in Strings》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

MD5 加密
MD5 加密

MD5 加密工具

SHA 加密
SHA 加密

SHA 加密工具