jQuery 基础语法

 

  

1
2
3
4
5
6
7
8
9
10
11
12
<head>
 
   <script src="../js/jquery-3.2.1.js"></script>
    <script src="../js/试试特效.js"></script> 
</head>
 
 
        <body>
    <p>11</p> <br>      <p>11</p><br>      <p>11</p><br>      <p>11</p>
       <button id="bindEvent">点我</button>
 
    </body>

     创建的js一定要在jQuery后面

  jQuery 基本语法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$(document).ready(function() {
            //alert("文档加载完毕");//当前函数触发文档加载完毕
            /*$("p").click(function() {
                $(this).hide();//点击p隐藏
            });*/
            /*$("#").click(function() {
                    alert("你好");
            });*/    //点击按钮,出你好
            /*$("#bindEvent").bind("click",clickhandler2);
            $("#bindEvent").bind("click",clickhandler3);*/ //可以同时绑定两个事件
            /*$("#bindEvent").unbind("click",clickhandler2);    */  //解绑事件
            //常用的事件方法    单击 $("#bindEvent").click(function() {
                // 双击 $("#bindEvent").dblclick(function() {
                //  鼠标移入    $("#bindEvent").mouseenter(function() {<br>              /* 鼠标移出*/    $("#bindEvent").mouseleave(function() {
                $(this).hide();
            });
    });
    //可以用on代替bind,用off代替unbind
    function clickhandler2(e){
     
            console.log("clickhandler2");
    }
     
    function clickhandler3(e){
     
            console.log("clickhandler3");
    }

 

     

 

 $(selector).action()

    美元符号定义

    选择符(selector) "查询"和查找HTML元素

    action(  ) 执行对元素的操作

 

    jQuery 可以通过一行简单的标记添加到网页中,是一个JS函数库

 

posted on   左剃头  阅读(214)  评论(0编辑  收藏  举报

努力加载评论中...

导航

点击右上角即可分享
微信分享提示