夺命雷公狗jquery---21-bind为jquery对象绑定相关事件

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <script src="js/jquery.js"></script>
        <script>
            //页面载入ready方法
            $(function(){
                //为按钮绑定单击事件
                $('#btnok').bind('click',function(){
                    alert('hello');
                });

                $('#btnok').bind('click',function(){
                    alert('world');
                });
            })
        </script>
    </head>
    <body>
        <input type="button" id="btnok" value="OK" />
    </body>
</html>

通过运行以上代码可知,在jQuery中,bind方法绑定采用的是事件监听的形式且其调整了兼容性以及事件触发顺序统一更改为正序触发。

原文地址:https://www.cnblogs.com/leigood/p/4911896.html