首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >文档-$( jQuery ).ready函数内部的函数

文档-$( jQuery ).ready函数内部的函数
EN

Stack Overflow用户
提问于 2011-07-22 02:30:50
回答 7查看 77.3K关注 0票数 35

在内部创建函数是否正确

$(document).ready(function() {

如下所示:

$(document).ready(function() {
     function callMe() {

     }
 });

在DOM准备就绪并触发ready()内的事件之前,不必调用.ready()内的函数。

只是为了澄清一点--这是说明这个问题的代码:

$(function() {
    var ind = 0;

    // some event is executed and changes the value of the ind

    // another event which affects the ind variable

    // and another one - after this event we call our function


    // there's another event - and we call our function again

我需要调用的函数需要ind变量的更新值-我想我可以将其作为参数传递,但有没有更好的方法呢?

另外--另一件重要的事情是function()也可以改变ind变量的值--例如递增它(ind++)。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6780890

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档