zoukankan      html  css  js  c++  java
  • JQuery事件绑定

    JQuery事件绑定

    两种方法:

    1. HTML属性去掉on(如onclike改为click)
    2. bind事件(bind:捆绑)

    这俩方法的参数都是“函数”——事件触发时执行的函数。

    <head>
    	<meta charset="utf-8" />
    	<title>事件绑定</title>
    	<script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
    	<script>
    		$(function() {
    			// 1.获取元素
    			// 2.绑定事件,使用匿名函数
    			$("#btn1").click(function() {
    				console.log("click:" + this);
    			});
    			$("#btn2").bind("click", function() {
    				console.log("bind click:" + this)
    			});
    		});
    	</script>
    </head>
    
    <body>
    	<input id="btn1" type="button" value="click事件" />
    	<input id="btn2" type="button" value="bind事件" />
    </body>
    
  • 相关阅读:
    软件工程概论
    软件工程概论
    JAVA
    JAVA
    C#字符补位
    C#绘图双缓冲
    C#中IP地址转换为数值的方法
    C#并行编程-并发集合
    C#委托
    C#事件(event)解析
  • 原文地址:https://www.cnblogs.com/tigerlion/p/11178579.html
Copyright © 2011-2022 走看看