JQuery的ready函数与JS的onload区别详解
来源:才华咖 本文已影响2.84W人
来源:才华咖 本文已影响2.84W人
JQuery的ready函数与JS的onload的区别:
1.执行时间
ad必须等到页面内包括图片的所有元素加载完毕后才能执行。
$(document)y()是DOM结构绘制完毕后就执行,不必等到加载完毕。
2.编写个数不同
ad不能同时编写多个,如果有多个ad方法,只会执行一个
$(document)y()可以同时编写多个,并且都可以得到执行
3.简化写法
ad没有简化写法
$(document)y(function(){})可以简写成$(function(){});
例子:
复制代码 代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"">
//js中window对象的onload属性执行jsFunction1函数
ad=jsFunction1;
//js中window对象的'onload属性执行jsFunction2函数
ad=jsFunction2;
//jquery的ready方法执行jqFunction1函数
$(document)y(jqFunction1);
//jquery的ready方法执行jqFunction2函数
$(document)y(jqFunction2);
//jsFunction1函数
function jsFunction1(){
alert("jsFunction1");
}
//jsFunction2函数
function jsFunction2(){
alert("jsFunction2");
}
//jqFunction1函数
function jqFunction1(){
alert("jqFunction1");
}
//jqFunction2函数
function jqFunction2(){
alert("jqFunction2");
}
ready和js中的onload的区别
让jQuery Mobile不显示loading界面的方法
To be really happy and really safe优秀英语作文
How Do My Parents Feel About My Education英语作文
MySQL安装时出现current root password的解决方法
ASandpiperToBringYouJoy英语阅读
jQuery 源码分析和Ready函数
jquery lazyload延迟加载的实现原理分析
《You Cant Judge a William by Its Cover》英语美文欣赏
《Are You Ready for a song 》 优秀教案
初三年级英语课文复习 Unit 1. Try not to translate every word
学个词Learn a Word-第2430课:documentary
英语阅读:Feelings of joy and thoughts from joy
Chinas Liu to seek injury advice in US soon英语作文
英国文学I wondered lonely as a cloud的赏析整理
英语Lesson8家庭作业:Dannys favourite colour
Journey to Australia的英语作文及翻译
学个词Learn a Word:casualty
公函与函的区别
java.util.ArrayDeque类使用方法介绍
考研数学一二三区别详细解读【精品多篇】
英语作文:Gulangyu,A fairyland in the world
五年级Lesson 2 What Are you doing ?优秀教案
英语阅读:Are You Tricked by These Optical Illusions
《UnitFourDoyoulikepears》优秀教案与反思
jQuery学习笔记之Helloworld教程
salad的复数与单数区别
《Are You Ready for a Quiz》优秀教案
Adventure Holidays教案
关于javascript中encodeURI和decodeURI的使用方法
《Are You Ready for a Quiz ?》优秀教案范文
whats your plan for dragon boat festival英语作文
英语作文Adjust Our Attitude Towards Study
A Story Of My Friend Who Ecel大学英语作文
英语阅读:VIT declines to acquire Ang Mo Kio property
英语满分作文:Reading-TheBestMeanstoAcquireknowledge
《Are You Ready for a Quiz》英语说课稿
What Did You Do Yesterday英语说课稿
JQuery的ready函数与JS的onload区别详解
Java 多线程之synchronized关键字详解
Too many essential for children to learn英语作文