亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

老師講的事件都體驗(yàn)了一遍,onchange,onsubmit 不會(huì)用

Original 2019-02-03 13:42:25 223
abstract:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>javascript之事件的使用方法</title></head><body><script type="text/

<!DOCTYPE html>

<html lang="en">

<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)移開" 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 寫進(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>



Correcting teacher:天蓬老師Correction time:2019-02-03 15:13:52
Teacher's summary:onchange(),這個(gè)事件, 因表單元素不同, 表現(xiàn)是不一樣的,例如input, 只有失去焦點(diǎn)才會(huì)觸發(fā),而select就不需要, 只要改變就會(huì)觸發(fā), 這些規(guī)則,只有多做才可以記住,沒有其它捷徑

Release Notes

Popular Entries