jQuery绑定事件 bind用法

xiaoxiao2021-02-28  77

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>绑定事件</title> </head> <body> <button class="box">点击弹出一个A</button> <input type="text" value="我是一个文本框"/> <script type="text/javascript" src="js/jquery-3.2.1.js"></script> <script type="text/javascript"> //创建jQuery函数 $(function(){ //1:绑定单击事件 //bind()方法,里面两个参数,一个是事件名称,一个是事件函数 $("button").bind('click',function(){ alert("A"); }) //2:可以绑定多个事件 $("input").bind('mousedown mouseover',function(){ $('button').css("background","red"); }) }) </script> </body> </html>
转载请注明原文地址: https://www.6miu.com/read-73381.html

最新回复(0)