您的位置:首页 > Web前端 > JavaScript

JS常见事件及其对应函数

2016-06-22 16:33 633 查看
JS常见事件及其对应函数如下图所示:


代码详例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Event_Page </title>
<link rel="stylesheet" type="text/css" href="eve01.css">
</head>
<body onload="onload_Fun(this)">
<button onclick="onc()"> 按钮 </button>
<script>
function onc(){
alert("on_clik_" +"event");
}
</script>

<!-- this 指向 函数-->
<div class="div" onmouseover="on_Over_Fun(this)" onmouseout="on_Out_Fun(this)"></div>
<script>
<!-- 鼠标 移入 移出 事件 -->
function on_Out_Fun(ooj){
ooj.innerHTML = "Out Function";
}
function on_Over_Fun(ooj){
ooj.innerHTML = "Over Function";
}
</script>

<form>
<input type="text" onchange="change_Fun(this)">
<input type="text" onselect="select_Fun(this)" onfocus="focus_Fun(this)">
</form>
<script>
<!-- 文本框 内容 改变 事件 -->
function change_Fun(bg){
alert("Change Func !");
}
<!-- 文本框 内容 选中 事件 -->
function select_Fun(bg){
bg.style.background="red";
}
<!-- 文本框 选中 事件 -->
function focus_Fun(bg){
bg.style.background="blue";
}
<!-- 网页加载完毕 事件 -->
function onload_Fun(bg){
alert("网页加载完毕!");
}
</script>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息