javascript简单事件添加

原创 2018-11-05 17:47:02 227
摘要:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> 姓名<input type="text"&n
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
姓名<input type="text" onfocus="myonfocus(this)" onblur="myonblur(this)">
密码<input type="password" onfocus="myonfocus1(this)" onblur="myonblur1(this)">
<br><br>
<input type="submit" value="提交" style="height:100px;width:100px;" onmousedown="myonmousedown(this)" onmouseup="myonmouseup(this)">




<script type="text/javascript">
function myonfocus(x){
x.style.backgroundColor="yellow"
}
function myonblur(x){
x.style.backgroundColor="white"
}
function myonfocus1(x){
x.style.backgroundColor="red"
}
function myonblur1(x){
x.style.backgroundColor="black"
}
function myonmousedown(y){
y.style.width="200px"
y.style.height="200px"
}
function myonmouseup(y){
y.style.width="100px"
y.style.height="100px"
}


</script>
</body>
</html>

通过事件的发生来回馈相应的动作,是现代web最重视的体验。

批改老师:韦小宝批改时间:2018-11-05 17:53:48
老师总结:是的!通过事件还可以完成一些华丽的动画,让用户体验更好!写的很不错!记得下次要加上总结哈!继续加油吧!

发布手记

热门词条