jQuery 基础语法

  

<head>

   <script src="../js/jquery-3.2.1.js"></script>
    <script src="../js/试试特效.js"></script>  
</head>


        <body>
    <p>11</p> 
      <p>11</p>
      <p>11</p>
      <p>11</p> <button id="bindEvent">点我</button> </body>

     创建的js一定要在jQuery后面

  jQuery 基本语法

$(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() {
              /* 鼠标移出*/    $("#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函数库

原文地址:https://www.cnblogs.com/zuo72/p/7844806.html