基础事件(上)

来源:互联网 发布:大数据运营平台 编辑:程序博客网 时间:2024/06/16 22:11
1 <form>2     <input type="submit" value="按钮" />3 </form>

事件:

  1 $(function () {  2   3     /*  4     $('input').bind('click', function () {  5         alert('弹窗!');  6     });  7   8       9     $('input').bind('click', fn); 10      11     function fn() { 12         alert('处理函数!') 13     } 14  15      16     $('input').bind('click mouseover', function () { 17         alert('弹窗!'); 18     }); 19  20      21     $('input').bind('mouseover mouseout', function () { 22         $('div').html(function (index, value) { 23             return value + '1'; 24         }); 25     }); 26  27      28     $('input').bind({ 29         mouseover : function () { 30             alert('移入'); 31         }, 32         mouseout : function () { 33             alert('移出'); 34         } 35     }); 36  37      38     $('input').bind({ 39         'mouseover' : function () { 40             alert('移入'); 41         }, 42         'mouseout' : function () { 43             alert('移出'); 44         } 45     }); 46  47      48     $('input').bind('click mouseover', function () { 49         alert('弹窗!'); 50     }); 51  52      53     $('input').bind('click', fn1); 54     $('input').bind('click', fn2); 55      56     function fn1() { 57         alert('fn1'); 58     } 59      60     function fn2() { 61         alert('fn2'); 62     } 63      64     //$('input').unbind();        //删除全部事件 65     //$('input').unbind('click');    //只删除click事件 66     $('input').unbind('click', fn2);  //删除click事件绑定了fn2的 67  68      69     $('input').click(function () { 70         alert('单击'); 71     }); 72      73     $('input').dblclick(function () { 74         alert('双击'); 75     }); 76      77     $('input').mousedown(function () { 78         alert('鼠标左键按下'); 79     }); 80      81     $('input').mouseup(function () { 82         alert('鼠标左键按下弹起'); 83     }); 84      85     $(window).unload(function () {            //一般unload卸载页面新版浏览器应该是不支持的,获取要设置一个。 86         alert('1');                                        //一般用于清理工作。 87     }); 88      89     $(window).resize(function () {             90         alert('文档改变了');                                     91     }); 92      93     $(window).scroll(function () {             94         alert('滚动条改变了');                                     95     }); 96     $('input').select(function () { 97         alert('文本选定'); 98     }); 99     100     $('input').change(function () {101         alert('文本改变');102     });103     */104 105     $('form').submit(function () {106         alert('表单提交!');107     });108     109     110     111 });

 

0 0
原创粉丝点击