1,$(document).ready(fn)
页面加载完毕 触发事件函数
2,$(document).load(fn)
如果绑定给window对象,则会在所有内容加载后触发,包括窗口,框架,对象和图像。如果绑定在元素上,则当元素的内容加载完毕后触发。
(上面两者区别在JQuery中,load是所有Dom元素创建完毕、图片、Css等都加载完毕后才被触发,而ready则是Dom元素创建完毕后就被触发,这样可以提高网页的响应速度。)
3.hover(moverfn,outfn)
当鼠标移动到一个匹配的元素上面时,会触发指定的第一个函数。当鼠标移出这个元素时,会触发指定的第二个函数。而且,会伴随着对鼠标是否仍然处在特定元素中的检测(例如,处在div中的图像),如果是,则会继续保持“悬停”状态,而不触发移出事件
例:
$('#menu li').hover(function() { var $this = $(this); $('a', $this).stop(true, true).animate({ 'bottom' : bottomhover }, 300); $('i', $this).stop(true, true).animate({ 'top' : '40px' }, 400); }, function() { var $this = $(this); $('a', $this).stop(true, true).animate({ 'bottom' : bottom }, 300); $('i', $this).stop(true, true).animate({ 'top' : '60px' }, 400); }); });