HTML基础知识(19)

1、jQuery动画

使用animate方法可设置

$('#div1').animate({

    width:300,

    height:300

},1000,swing,function(){

    alert('done!');

});

2、尺寸相关、滚动事

1、获取和设置元素的尺寸

width()、height()    获取元素width和height 

innerWidth()、innerHeight()  包括padding的width和height 

outerWidth()、outerHeight()  包括padding和border的width和height 

outerWidth(true)、outerHeight(true)   包括padding和border以及margin的width和height

2、获取元素相对页面的绝对位置:offset()

3、获取可视区高度:$(window).height();

4、获取页面高度:$(document).height();

5、获取页面滚动距离:$(document).scrollTop(); 

$(document).scrollLeft();

6、页面滚动事件:$(window).scroll(function(){    })

jQuery事件 :事件函数列表:

blur() 元素失去焦点

focus() 元素获得焦点

change() 表单元素的值发生变化

click() 鼠标单击

dblclick() 鼠标双击

mouseover() 鼠标进入(进入子元素也触发)

mouseout() 鼠标离开(离开子元素也触发)

mouseenter() 鼠标进入(进入子元素不触发)

mouseleave() 鼠标离开(离开子元素不触发)

hover() 同时为mouseenter和mouseleave事件指定处理函数

mouseup() 松开鼠标

mousedown() 按下鼠标

mousemove() 鼠标在元素内部移动

keydown() 按下键盘

keypress() 按下键盘

keyup() 松开键盘

load() 元素加载完毕

ready() DOM加载完成

resize() 浏览器窗口的大小发生改变

scroll() 滚动条的位置发生变化

select() 用户选中文本框中的内容

submit() 用户递交表单

toggle() 根据鼠标点击的次数,依次运行多个函数

unload() 用户离开页面

主动触发与自定义事件:

//给element绑定hello事件

element.bind("hello",function(){

    alert("hello world!");

});

//触发hello事件

element.trigger("hello");

你可能感兴趣的:(HTML基础知识(19))