外觀效果
addClass(class)和removeClass(class)
代碼:
$(".stripe tr").mouseover(function(){
$(this).addClass("over");}).mouseout(function(){
$(this).removeClass("over");})
});
也可以寫(xiě)成:
$(".stripe tr").mouseover(function() { $(this).addClass("over") });
$(".stripe tr").mouseout(function() { $(this).removeClass("over") });
作用:為指定的元素添加或移除樣式,從而實(shí)現(xiàn)動(dòng)態(tài)的樣式效果,上面的實(shí)例中實(shí)現(xiàn)鼠標(biāo)移動(dòng)雙色表格的代碼。
css(name,value)
代碼:
$("p").css("color","red");
作用:很簡(jiǎn)單,就是在匹配的元素中,設(shè)置一個(gè)樣式屬性的值。這個(gè)個(gè)人感覺(jué)和上面的addClass(class)有點(diǎn)類似。
slide(),hide(),fadeIn(), fadeout(), slideUp() ,slideDown()
代碼:
$("#btnShow").bind("click",function(event){ $("#divMsg").show() });
$("#btnHide").bind("click",function(evnet){ $("#divMsg").hide() });
作用:jQuery中提供的比較常用的幾個(gè)動(dòng)態(tài)效果的函數(shù)。還可以添加參數(shù):show(speed,[callback])以優(yōu)雅的動(dòng)畫(huà)顯示所有匹配的元素,并在顯示完成后可選地觸發(fā)一個(gè)回調(diào)函數(shù)。
animate(params[,duration[,easing[,callback]]])
作用:制作動(dòng)畫(huà)效果用到的函數(shù),功能非常的強(qiáng)大,可以連續(xù)使用此函數(shù)。