以下是JQuery常用到的一些事件
$(document).ready(function):将函数绑定到文档的就绪事件(当文档完成加载时)
$(selector).load(function):触发或将函数绑定到元素或子元素加载后的事件
$(selector).unload(function):触发或将函数绑定到离开当前页面后的事件
$(selector).click(function):触发或将函数绑定到被选元素的点击事件
$(selector).dblclick(function):触发或将函数绑定到被选元素的双击事件
$(selector).focus(function):触发或将函数绑定到被选元素的获得焦点事件
$(selector).blur(function):触发或将函数绑定到被选元素的失去焦点事件
$(selector).mouseover(function):触发或将函数绑定到被选元素的鼠标悬停事件
$(selector).mouseout(function):触发或将函数绑定到被选元素的鼠标移开时事件
$(selector).mousedown(function):触发或将函数绑定到被选元素的鼠标按钮按下事件
$(selector).mousemove(function):触发或将函数绑定到被选元素的鼠标移动事件
$(selector).mouseup(function):触发或将函数绑定到被选元素的鼠标按键松开事件
以下举一个列子:
<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<head>
<script src="jquery-1.12.0.js"></script>
</script>
<script type="text/javascript">
$(document).ready(function(){
alert("文本加载准备效果!");
$("p").mouseover(function(){
$("p").css("background-color","yellow");
});
$("p").mouseout(function(){
$("p").css("background-color","#E9E9E4");
});
$("#button1").click(function(){
alert("单击效果!");
});
$("#button2").dblclick(function(){
alert("双击效果!");
});
$("input").focus(function(){
$("input").attr("value","获取焦点");
});
$("input").blur(function(){
$("input").val("失去焦点");
});
});
</script>
</head>
<body>
<p style="background-color:#E9E9E4">移动鼠标指针</p>
输入来获取焦点: <input type="text" /><br>
<button id="button1">单击效果</button><button id="button2">双击效果</button>
</body>
</html>