$(function(){})和$(document).ready(function(){}) 的用法
当文档载入完毕就执行,以下几种效果是等价的:
1.
$(function(){ //这个就是jQuery ready()的简写,即下2的简写
// do something
});
2.
$(document).ready(function(){
//do something
})
3.
$().ready(function(){ //默认参数是:document
//do something
})
function one(){
alert("one");
}
function two(){
alert("two");
}
$(document).ready(function(){
one();
});
$(document).ready(function(){
two();
});
//运行代码后
//先是:one
//先是:two
function one(){
alert("one");
}
function two(){
alert("two");
}
window.onload=one;
window.onload=two;
//运行代码后只有 two
随机推荐
- 保存现场数据和状态:onSaveInstanceState\onRestoreInstanceState\onCreate()
当某个activity变得“容易”被系统销毁时,该activity的onSaveInstanceState就会被执行,除非该activity是被用户主动销毁的,例如当用户按BACK键的时候. 注意上面 ...
- 用C++,调用浏览器打开一个网页
http://blog.csdn.net/heaven13483/article/details/9369029
- php大力力 [030节] php设计系统后台菜单
php大力力 [030节] php设计系统后台菜单 2015-08-28 00:11 开始设计: 2015-08-28 01:29 设计完毕. php大力力 [030节] php设计系统后台菜单 1. ...
- fedora下vim配置
一.安装 1)dnf安装 fedora22以下 sudo yum install vim fedora22及以上 sudo dnf install vim 如果遇到下面类似的错误 .gz from : ...
- css if hack之兼容ie
1.Css if hack条件语法< !--[if IE]> Only IE <![endif]-->仅所有的WIN系统自带IE可识别< !--[if IE 5.0]&g ...
- JLOI 提示问题
按照题目意思模拟即可. Program XJOI2265; ..] of char=('a','e','i','o','u','A','E','I','O','U'); var s:ansistrin ...
- The u32 classifier
The u32 classifier The U32 filter is the most advanced filter available in the current implementatio ...
- Sublime Text 2 安装主题的方法
主题下载 下载一个主题,例如: https://github.com/hyspace/st2-reeder-theme 里面起作用的文件有两个: Reeder.sublime-theme Earths ...
- Why did Jimmy Wales invest in Quora? Is he afraid that it will take over Wikipedia?
QUESTION: Why did Jimmy Wales invest in Quora? Is he afraid that it will take over Wikipedia? Answer ...
- C# 接受邮件 两种方式
有些累了,不想写太多,直接把代码贴上 EWS 源码 POP协议 源码 PS:如果我们发现引入的一个dll,能够添加引用,但是一编译又找不到,那么很有可能是.net framework 版本不同. 不如 ...