jquery 学习笔记

学习jquery的事件操作
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>jquerytest</title>
</head>
<body>
 <p>hello  world 我是第一个p</p>
 <p class="dada">hello  world 我的是二个p</p>
 <p class="dada">hello  world 我的是二个p</p>
 <p class="dada">hello  world 我的是二个p</p>
 <p>hello  world 我的是二个p</p>
 <p id="test">hello  world 我的是二个p</p>

 <div id="one">
  <h2>one artic</h2>

 </div>
 <div id="two">
 <h2>two artic</h2>

 </div>
 <div id="three">
 <h2>three artic</h2>

 </div>
 <div id="four">
 <h2>four artic</h2>
 <input>
 </div>

 <button>按钮</button>
   <script src="js/jquery.js"></script>
   <script>
       //1,加载完dom节点后就会执行这个方法
//     $(document).ready(function () {
//      $('button').click(function () {
//          $('.dada').hide();
//      });
//     });
   //2,也可以使用这个方法
    $(function () {
          $('p').click(function () {
              $('p').hide();
          });
          //鼠标进入的时候mouseenter()触发的事件
          $('#test').mouseenter(function () {
              alert('we are famuly');
          });
         //离开的时候触发这个mouseleave()事件
          $('.dada').mouseleave(function () {
              alert('we are family yes');
          });
         $('#one').mousedown(function () {
             alert('welcome one');
         });
         //鼠标点击和离开的时候触发的事件
         $("#one").mouseup(function(){
            alert("Mouse up over one!");
            });
         $('#two').hover(function () {
             alert('hello two')
         },function () {
             alert('hello two left')
         });
        $('#four input').focus(function () {
            $(this).css('background-color','#00ffff');
        });
        //上下这两个方法是 input有焦点个失去焦点会调用的两个方法
        $('#four input').blur(function () {
            $(this).css('background-color','#ffff00');
        });
    });
   </script>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值