鼠标事件:
- click - - - - - - - - - - - - - 点击
- mouseover - - - - - - - - -覆盖
- mouseout - - - - - - - - - 移除
键盘事件:
- keydown - - - - - - - - - - - -按下
- keyup - - - - - - - - - - - - -按下后松开
- keypress - - - - - - - - - - - -输入任意键
表单事件:
- focus - - - - - - - - - - - - - - -获得焦点
- blur - - - - - - - - - - - - - - -失去焦点
绑定事件:
移除事件:
鼠标悬停事件:
鼠标连续点击:
动画:
- show - - - - - - - - - - - -显示
- hide - - - - - - - - - - - -隐藏
- toggle - - - - - - - - - - - -显示/隐藏
- fadeIn - - - - - - - - - - - -淡入
- fadeOut - - - - - - - - - - - -淡出
- slideDown - - - - - - - - - - - -收缩
- slidUp - - - - - - - - - - - - - - -伸张
1)鼠标事件:
<p>鼠标事件</p>
$("p").click(function(){
$(this).css("background","red")
})
$("p").mousemove(function(){
$(this).css("background","green")
})
$("p").mouseout(function(){
$(this).css("background","white")
})
2)键盘事件:
<input>
$(document).keydown(function(){
if(event.keyCode == "65")
alert("A按下")
})
$(document).keyup(function(){
if(event.keyCode == "66")
alert("B松开")
})
var i=0;
$(document).keypress(function(){
i+=1;
alert("输入字母数:"+i);
})
3)表单事件:
<input>
$("input").focus(function(){
$(this).css("background","plum");
}).blur(function(){
$(this).css("background","white");
})
4)绑定事件:
<p>鼠标事件</p>
$("p").bind({
"mousemove":function(){
$(this).css("background", "green")
},"mouseout":function() {
$(this).css("background", "white")
},"click":function() {
$(this).css("background", "red")
}
})
5)移除事件:
<p>鼠标事件</p>
$("p").unbind("mouseout");//移除一事件
$("p").unbind();//移除全部事件
6)鼠标悬停事件:
<p>鼠标事件</p>
$("p").hover(function(){
$(this).css("background", "green")
},function(){
$(this).css("background", "white")
}
)
7)鼠标连续点击事件:
$("p").toggle(
function(){
$(this).css("background", "green")
},function(){
$(this).css("background", "red")
},function(){
$(this).css("background", "black")
},function(){
$(this).css("background", "yellow")
}
)
8)动画:
$("p").hide(3000);
$("p").show(3000);
$("button").click(function(){
$("p").toggle();
})
$("button").click(function(){
$("img").fadeOut(3000);
$("img").fadeIn(3000);
})
$("button").click(function(){
$("img").slideUp(3000);
$("img").slideDown(3000);
})