jQuery函数 [英] jQuery Functions

查看:104
本文介绍了jQuery函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $(function myFunction(){
...
});

我的意思是为什么在$

解决方案

我认为你的意思是这样的:

  $(function ){
...
});

这是简写:

  $(document).ready(function(){
...
});

它为准备好一个处理程序事件,所以函数中的代码将在文档加载后立即运行。


What is the use of writing a jQuery function like so...

$(function myFunction() {
    ...
});

What i mean is why wrap the function in $

解决方案

I think that you mean like this:

$(function() {
  ...
});

This is shorthand for:

$(document).ready(function() {
  ...
});

What it does is registering a handler for the ready event, so the code in the function will be run as soon as the document has loaded.

这篇关于jQuery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆