jquery事件命名空间

    xiaoxiao2021-03-28  41

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jquery事件命名空间</title> <script src="js/jquery.min.js"></script> <style> .btn{height:50px;width:50px;border:1px solid #000;margin:10px;} </style> </head> <body> <div class="wrap"> <input type="button" value="按钮" class="btn"> </div> <script> $(function(){ $(".btn").on("click.aaa",function () { //绑定第一个点击事件 alert(11); }); $(".btn").on("click.bbb",function () { //绑定第二个点击事件 alert(22); $(".btn").off("click.aaa"); //去除第一个点击事件 }); /*$(".btn").one("click.aaa",function () { //绑定的第一个点击事件,可以采用one()一次执行方法 alert(11); });*/ }); </script> </body> </html>
    转载请注明原文地址: https://ju.6miu.com/read-664664.html

    最新回复(0)