164.jQuery動(dòng)畫(huà):
使用animate方法可設(shè)置
$('#div1').animate({
? ? width:300,
? ? height:300
},1000,swing,function(){
? ? alert('done!');
});
165.尺寸相關(guān)、滾動(dòng)事件:
1、獲取和設(shè)置元素的尺寸
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、獲取元素相對(duì)頁(yè)面的絕對(duì)位置:offset()
3、獲取可視區(qū)高度:$(window).height();
4、獲取頁(yè)面高度:$(document).height();
5、獲取頁(yè)面滾動(dòng)距離:$(document).scrollTop();?
$(document).scrollLeft();
6、頁(yè)面滾動(dòng)事件:$(window).scroll(function(){? ? })
166.jQuery事件 :事件函數(shù)列表:
blur() 元素失去焦點(diǎn)
focus() 元素獲得焦點(diǎn)
change() 表單元素的值發(fā)生變化
click() 鼠標(biāo)單擊
dblclick() 鼠標(biāo)雙擊
mouseover() 鼠標(biāo)進(jìn)入(進(jìn)入子元素也觸發(fā))
mouseout() 鼠標(biāo)離開(kāi)(離開(kāi)子元素也觸發(fā))
mouseenter() 鼠標(biāo)進(jìn)入(進(jìn)入子元素不觸發(fā))
mouseleave() 鼠標(biāo)離開(kāi)(離開(kāi)子元素不觸發(fā))
hover() 同時(shí)為mouseenter和mouseleave事件指定處理函數(shù)
mouseup() 松開(kāi)鼠標(biāo)
mousedown() 按下鼠標(biāo)
mousemove() 鼠標(biāo)在元素內(nèi)部移動(dòng)
keydown() 按下鍵盤(pán)
keypress() 按下鍵盤(pán)
keyup() 松開(kāi)鍵盤(pán)
load() 元素加載完畢
ready() DOM加載完成
resize() 瀏覽器窗口的大小發(fā)生改變
scroll() 滾動(dòng)條的位置發(fā)生變化
select() 用戶選中文本框中的內(nèi)容
submit() 用戶遞交表單
toggle() 根據(jù)鼠標(biāo)點(diǎn)擊的次數(shù),依次運(yùn)行多個(gè)函數(shù)
unload() 用戶離開(kāi)頁(yè)面
167.主動(dòng)觸發(fā)與自定義事件:
//給element綁定hello事件
element.bind("hello",function(){
? ? alert("hello world!");
});
//觸發(fā)hello事件
element.trigger("hello");