JavaScript事件

原创2018-11-23 21:28:4571
摘要:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>js事件</title> </head> <script type="text/javascript"> func
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>js事件</title>
</head>
<script type="text/javascript">
function fun(){
alert("请输入名字")
}
function content(){
alert("登陆中。。")
}
function change(x){
x.style.borderRadius="5px"
}

</script>

<body onload="content()">
 姓名:<input type="text" placeholder="请输入名字" onmouseout="fun()">
  <input type="submit" value="输入" onclick="change(this)">
</body>
</html>

获取属性得时候使用驼峰式写法:
x.style.borderRadius="5px";
onclick     当用户点击鼠标时;
onload      一张页面或一幅图像完成加载;
onkeyup     某个键盘按键被按开;
onmouseout  鼠标从某元素移开
onfocus     元素获得焦点;
onblur      元素失去焦点;
...


批改老师:灭绝师太批改时间:2018-11-24 09:12:25
老师总结:事件方法要好好测试一下奥,把学习的知识点用到案例中才是王道!

发布手记

热门词条