$(document).load();

当web页面以及其附带的资源文件,如CSS,Scripts,图片等,加载完毕后执行此方法。
常用于检测页面(及其附带资源)是否加载完毕。

$(document).ready();
当页面DOM对象加载完毕,web浏览器能够运行JS时,此方法即被触发。如果你想尽快执行JS,可以使用此方法。[在html的头部的script标签中的,不处于ready()中的JS代码将早于ready()执行]

$(document).unload();
此事件在停止浏览页面的时候触发,此操作可能存在于刷新操作/F5,单击上一页按钮,进入其他页面或关闭整个tab或窗口。

总而言之,他们的调用顺序是 ready() >> load() >> unload() 。

$(document).load();

Will execute after the page along with all its contents are done loading. This means that all images, CSS (and content defined by CSS like custom fonts and images), scripts, etc. are all loaded. This happens event fires when your browser's "Stop" -icon becomes gray, so to speak. This is very useful to detect when the document along with all its contents are loaded.

$(document).ready();

This on the other hand will fire as soon as the web browser is capable of running your JavaScript, which happens after the parser is done with the DOM. This is useful if you want to execute JavaScript as soon as possible.

$(document).unload();

This event will be fired when you are navigating off the page. That could be Refresh/F5, pressing the previous page button, navigating to another website or closing the entire tab/window.

To sum up, ready() will be fired before load(), and unload() will be the last to be fired.

http://stackoverflow.com/questions/2683072/jquery-events-load-ready-unload

以上转自:http://blog.csdn.net/after2010/article/details/9037069

刚开始接触jquery,很多东西不熟悉在用$("#id")来获得页面的input元素的时候,发现$("#id").value不能取到值
 
后来终于在伟大的百度帮助下,找到了问题的原因:

复制代码代码如下:
$("")是一个jquery对象,而不是一个dom element 
value是dom element的属性 
jquery与之对应的是val 
val() :获得第一个匹配元素的当前值。 
val(val):设置每一个匹配元素的值。 

所以,代码应该这样写:

复制代码代码如下:
取值:val = $("#id")[0].value; 
赋值: 
$("#id")[0].value = "new value"; 
或者$("#id").val("new value");

或者这样也可以:val = $("#id").attr("value");

最新文章

  1. webform:图片水印、验证码制作
  2. 跟我一起数据挖掘(21)——redis
  3. foreach statement cannot operate on variables of type 'System.Web.UI.WebControls.Table' because 'System.Web.UI.WebControls.Table' does not contain a public definition for 'GetEnumerator'
  4. 算法练习之leetcode系列1-3
  5. jquery选择器之内容选择器
  6. PIC32MZ tutorial -- Key Debounce
  7. asp.net 微信企业号办公系统-表单及流程设计配置实例
  8. nanakon
  9. 手动编译Spring4.2源码,以及把源码导入myEclipse中
  10. 如何在服务(Service)程序中显示对话框
  11. 外观模式之C++实现
  12. c语言对齐问题
  13. 规范 : angular 组合 jquery plugin
  14. Linux 虚拟内存
  15. Mac下GTest的基本使用
  16. 解决git 不同branch 下node_moudes不同步的问题
  17. 【转载】JAVA基础:注解
  18. 破解UltraEdit(Ver20.00.0.1040),无限试用
  19. NHibernate 学习导航
  20. Informatica 常用组件Aggregator之二 分组依据端口

热门文章

  1. 【iOS开发-35】有了ARC内存管理机制,是否还须要操心内存溢出等问题?——面试必备
  2. C#中byte[] 与指针
  3. Linq 中的Select事例
  4. zTouch-移动端触屏开发利器(zepto touch扩展)
  5. 2016年gift上线相关知识点记录
  6. Android学习之简单的数据存储
  7. mysql 重启
  8. UIButton 文档翻译(持续更新)
  9. linux中断--进程上下文和中断上下文
  10. linux系统下memcached启动正常但程序无法连接的问题解决