jQuery文档学习笔记

jQuery(callback)

   

概述

$(document).ready()的简写。    

容许你绑定一个在DOM文档载入完成后执行的函数。这个函数的做用如同$(document).ready()同样,只不过用这个函数 时,须要把页面中全部须要在 DOM 加载完成时执行的$()操做符都包装到其中来。从技术上来讲,这个函数是可连接的--但真正以这种方式连接的状况并很少。 你能够在一个页面中使用任意多个$(document).ready事件。参考 ready(Function) 获取更多 ready 事件的信息。javascript

   

参数

   

callbackFunctionV1.0

当DOM加载完成后要执行的函数java

       

示例

   

描述:

当DOM加载完成后,执行其中的函数。函数

jQuery 代码:spa

$(function(){
  // 文档就绪});
 

   

描述:

使用 $(document).ready() 的简写,同时内部的 jQuery 代码依然使用 $ 做为别名,而无论全局的 $ 为什么。code

jQuery 代码:事件

jQuery(function($) {
  // 你能够在这里继续使用$做为别名...});
  • API

jQuery.data() Store arbitrary data associated with the specified element add/or return the value that setip

jQuery.data(element, key, value) 

element: A Dom element to associated with the dataci

key: A string naming the piece of data to set  element

value: The newdata value, Any javascript type except undefined文档

相关文章
相关标签/搜索