$(function(){});

来源:互联网 发布:软件开发编程招聘 编辑:程序博客网 时间:2024/05/18 01:12

jQuery( callback )Returns: jQuery

Description: Binds a function to be executed when the DOM has finished loading.

  • version added: 1.0jQuery( callback )

    • callback
      Type: Function()
      The function to execute when the DOM is ready.

This function behaves just like $( document ).ready(), in that it should be used to wrap other $() operations on your page that depend on the DOM being ready. While this function is, technically, chainable, there really isn"t much use for chaining against it.

Examples:

Example: Execute the function when the DOM is ready to be used.

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

Example: Use both the shortcut for $(document).ready() and the argument to write failsafe jQuery code using the $ alias, without relying on the global alias.

1
2
3
jQuery(function( $ ) {
// Your code using failsafe $ alias here...
});
0 0