在页面完全加载后加载jquery [英] load jquery after the page is fully loaded

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

问题描述

我正在寻找一种在页面完全加载后加载jquery的方法。

这里有很多关于它的问题和答案,但都描述了如何在页面或jquery完全加载后运行需要jquery的脚本。

我在寻找的是加载页面,然后调用jquery和jquery加载后调用函数。例如:

  document.onload = function(){
var fileref = document.createElement('script') ;
fileref.setAttribute(type,text / javascript);
fileref.setAttribute(src,'http://code.jquery.com/jquery-1.7.2.min.js');
//这里我需要一个事件来知道jquery是
//被加载来运行需要jquery
}

解决方案

试试这个:

  $(document).ready(function(){
//当文档准备就绪时
//做某事
});


I'm looking for a way to load jquery after the page is fully loaded.
well there are lots of questions and answers about it in here, but all describe how to run a script that needs jquery after either page or jquery fully loaded.
What I'm looking for is to load the page and then call jquery and after the jquery is loaded call the functions. something like:

document.onload=function(){
   var fileref=document.createElement('script');
  fileref.setAttribute("type","text/javascript");
  fileref.setAttribute("src", 'http://code.jquery.com/jquery-1.7.2.min.js');
//Here I need an event to know that jquery is 
//loaded to run stuff that needs jquery
}

解决方案

Try this:

 $(document).ready(function() {
// When the document is ready
// Do something  
});

这篇关于在页面完全加载后加载jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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