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

javascript事件入門實(shí)例

Original 2018-12-26 21:11:36 179
abstract:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>javascript事件入門實(shí)例</title> <script type="text/javascript"> fun
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>javascript事件入門實(shí)例</title>
	<script type="text/javascript">
function myonfocus(a){
a.style.background="black"
}
function myonblur(b){
b.style.background="yellow"
}
function myonchange(){
	var c=document.getElementById("aname")
c.value = c.value.toUpperCase()
}
function myonkeydown(d){
alert('按了一個按鍵吧?')

}
function myonkeyup(e){
	alert('最后還是松開了吧?')
}
function myonkeypress(f){
	alert('按了再松開')
}
function myonmousedown(g){
g.style.background="green"
}
function myonmousemove(h){
h.style.background="#FF44AA"
}
function myonmouseout(j){
j.style.background="#FFB7DD"
}
function myonmouseover(k){
k.style.background="#444444"
}
function myonmouseup(l){
l.style.background="#000000"
}
function myonsubmit(){
	prompt('再次確認(rèn)嗎?')
}
</script>
</head>
<body><!--  onload="alert('頁面加載完成')" -->
<div><h3>下面是javascript事件的入門實(shí)例</h3></div>
	<div>
鼠標(biāo)點(diǎn)擊文本框變黑色;然后點(diǎn)擊文本框外邊黃色:<input type="text" onfocus="myonfocus(this)" onblur="myonblur(this)">
	</div>
	<div>輸入小寫字母后,鼠標(biāo)點(diǎn)擊文本框外,自動轉(zhuǎn)換為大寫字母:<input type="text" id="aname" onchange="myonchange()"></div>
<div>
點(diǎn)擊按鈕,彈出對話框:<button type="botton" onclick="alert('歡迎來到本站!')">點(diǎn)我</button>
</div>
<div>雙擊“hello”,彈出提示框:<span ondblclick="prompt('點(diǎn)了兩次!')">hello</span></div>
<div>
在文本框內(nèi)按任意鍵:<input type="text" onkeydown="myonkeydown(this)">
</div>
<div>在文本框按任意鍵后松開:<input type="text" onkeyup="myonkeyup(this)"></div>
<div>在文本框按任意字母鍵(英文狀態(tài))后松開會提示內(nèi)容:<input type="text" onkeypress="myonkeypress(this)"></div>
<div>按F5刷新頁面看到提示信息</div>
<div>在下面方形內(nèi)按下鼠標(biāo),背景將會變色:<div style="width:50px;height:50px;border:1px solid #ccc;background:yellow" onmousedown="myonmousedown(this)"></div></div>
<div>鼠標(biāo)在下面長方形框內(nèi)移動,背景將會變色:<div style="width:50px;height:80px;border:1px solid #ccc;background: #888888" onmousemove="myonmousemove(this)"></div></div>
<div>鼠標(biāo)從下面的長方形框內(nèi)移出,背景顏色會變色:<div style="width:100px;height:80px;border:1px solid #C10066" onmouseout="myonmouseout(this)"></div></div>
<div>鼠標(biāo)移到下面長方形框內(nèi),背景將會變色:<div style="width:100px;height:70px;border:1px solid #DDDDDD" onmouseover="myonmouseover(this)"></div></div>
<div>鼠標(biāo)在下面正方形框內(nèi)被松開,則背景會變色:<div style="width:70px;height:70px;border:1px solid #A20055" onmouseup="myonmouseup(this)"></div></div>
<div>點(diǎn)擊提交按鈕,會彈出提示框:<form action="#" onsubmit="myonsubmit()"><input type="submit"></form></div>
</body>
</html>


Correcting teacher:韋小寶Correction time:2018-12-27 09:19:32
Teacher's summary:現(xiàn)在是不是感覺前端還是很有意思很好玩的對吧,jQuery和js中的很多事件都是很有意思的!課后記得多練習(xí)

Release Notes

Popular Entries