abstrak:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>javascript之事件的使用方法</title></head><body><script type="text/javascript">
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>javascript之事件的使用方法</title>
</head>
<body>
<script type="text/javascript">
function shijian1(x) {
x.style.background="green"
//為什么我用backgroudcolor就不行呢?老師
}
function shijian2(y) {
y.style.background="red"
}
function shijian3() {
Document.getElementById("a").value="who cares!"
}
function shijian4() {
alert("你確定提交了嗎?不好好考慮一下了")
}
</script>
1. onfocus:<input type="text" style="width:800px ;height:50px; border-radius: 200px;font-size: 28px;" onfocus="shijian1(this)" value="我是onfocus,點(diǎn)擊這里會(huì)變綠哦!不信你試試" onblur="shijian2(this)"> <br><br>
<!-- // value值是框里的提示信息 -->
2. onmouseover:<input type="text" style="width:800px ;height:50px; border-radius: 400px;font-size: 28px;" value="我是onmouseover,鼠標(biāo)到這里這里會(huì)變紅哦!不信你試試" onmouseover="shijian2(this)"> <br><br>
3. onmouseup:<input type="text" style="width:800px ;height:50px; border-radius: 400px;font-size: 28px;" value="我是onmouseup,鼠標(biāo)鍵抬起,這里這里會(huì)變紅哦!不信你試試" onmouseup="shijian2(this)"> <br><br>
4.onmouseout:<input type="text" style="width:800px ;height:50px; border-radius: 400px;font-size: 28px;" value="我是onmouseout,當(dāng)鼠標(biāo)移開(kāi)" onmouseover="shijian1(this)"> <br><br>
5.鼠標(biāo)按下onmousedown:<input type="text" style="width:800px ;height:50px; "onmousedown="shijian1(this)"> <br><br>
6.onclick <button type='button' onclick="shijian1(this)">點(diǎn)我!</button> <br><br>
7.ondbclick <button type='button' onclick="shijian2(this)">雙擊點(diǎn)我!</button> <br><br>
8.onblur 寫(xiě)進(jìn)第一條了 <br><br>
9.onchange<input type="text" id="a" style="width:800px ;height:50px; " onchange="shijian3(this)" > <br><br>
<!-- onchange不會(huì)用 -->
10.onsubmit <button type='button' onclick="shijian4(this)">提交!</button> <br><br><br><br>
<!-- 不會(huì)用提交功能,還不如用onclick呢是不是? -->
</body>
</html>