JS事件的学习

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>js的事件学习</title>
        <script type="text/javascript">
            //单击事件      
            function testOnclick(){
                alert("大家好,我是张三");
            }
            //双击事件
            function testOndblclick(){
                alert("大家好,我是李四");
            }
            //鼠标悬停事件
            function testOnmouseover(){
                alert("我进来了");
            }
            //鼠标移出事件
            function testOnmouseout(){
                alert("我出去了");
            }
            //鼠标移动事件
            function testOnmousemove(){
                alert("我移动了");
            }
            //页面加载事件
            function testOnload(){
                alert("我被加载了");
            }
            //失去焦点事件
            function testOnblur(){
                alert("失去焦点事件");
            }
            //获取焦点事件
            function testOnfocus(){
                alert("获得焦点事件");
            }
        </script>
        <style type="text/css">
            #div01{
                border: solid 1px;
                width: 200px;
                height: 200px;
                background-color: bisque;
            }
            #div02{
                border: solid 1px;
                width: 200px;
                height: 200px;
                background-color: aquamarine;
            }
        </style>
    </head>
    <body onload="testOnload()">
        <h3>js事件的学习</h3>
        <hr />
        <input type="button" id="" name="" value="单击事件" onclick="testOnclick()" />
        <input type="button" id="" name="" value="双击事件" ondblclick="testOndblclick()" />
        <div id="div01" onmouseover="testOnmouseover()" onmouseout="testOnmouseout()">
            测试鼠标悬停跟移出事件
        </div>
        <div id="div02" onmousemove="testOnmousemove()">
            测试鼠标移动事件
        </div>
        <hr />
        <input type="text" id="" name="" value="" onblur="testOnblur()"/>
        <input type="text" id="" name="" value="" onfocus="testOnfocus()"/>
    </body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值