在$(document).ready(...)旁边加载一次? jQuery的 [英] Load one time beside the $(document).ready(...) ? Jquery

查看:186
本文介绍了在$(document).ready(...)旁边加载一次? jQuery的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在触发一个仅需要加载一次的函数时遇到问题,但是我不想将其放入:

I have a problem with triggering a function which needs to be loaded only one time.But I don't want to put it into:

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

});

我想单独运行它.

我尝试过:

 jQuery(document).one(function () {
        myfunction();
    });

和其他一些东西. 但是无法解决.

and some other stuff. But couldn't solve it.

更新:

我在ready()上安装了Web服务:

I have my webservice on ready():

jQuery(document).ready(function ($) {
    PageMethods.myWebSer(suc, fail);
});

function suc(){
//I want to run my function here , but only one time
//Examplle
 //jQuery(document).one(function () {
          //  myfunction();
       // });
}

谢谢

推荐答案

只需添加另一个readyload函数:您可以拥有任意数量的函数,它们都将按顺序调用:

Just add another ready or load function : you may have as many as you want, they will all be called in order :

jQuery(document).ready(function() {
   // this will be run
});
jQuery(document).ready(function() {
   // and this one too (after the other one)
});

这篇关于在$(document).ready(...)旁边加载一次? jQuery的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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