返回微博1 你好...登陆

微博1 你好

杨雪~2019-02-03 15:10:221474

<!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,点击这里会变绿哦!不信你试试" onblur="shijian2(this)"> <br><br>

<!-- // value值是框里的提示信息 -->

2. onmouseover:<input type="text" style="width:800px ;height:50px; border-radius: 400px;font-size: 28px;" value="我是onmouseover,鼠标到这里这里会变红哦!不信你试试" onmouseover="shijian2(this)"> <br><br>

3. onmouseup:<input type="text" style="width:800px ;height:50px; border-radius: 400px;font-size: 28px;" value="我是onmouseup,鼠标键抬起,这里这里会变红哦!不信你试试" onmouseup="shijian2(this)"> <br><br>

4.onmouseout:<input type="text" style="width:800px ;height:50px; border-radius: 400px;font-size: 28px;" value="我是onmouseout,当鼠标移开" onmouseover="shijian1(this)"> <br><br>

5.鼠标按下onmousedown:<input type="text" style="width:800px ;height:50px; "onmousedown="shijian1(this)"> <br><br>

6.onclick   <button type='button' onclick="shijian1(this)">点我!</button> <br><br>

7.ondbclick  <button type='button' onclick="shijian2(this)">双击点我!</button> <br><br>

8.onblur 写进第一条了 <br><br>

9.onchange<input type="text" id="a" style="width:800px ;height:50px; "  onchange="shijian3(this)" > <br><br>

<!-- onchange不会用 -->

10.onsubmit   <button type='button' onclick="shijian4(this)">提交!</button> <br><br><br><br>

<!-- 不会用提交功能,还不如用onclick呢是不是? -->

</body>

</html>



最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送