jquery中bind函数绑定多个事件

来源:互联网 发布:易语言php网络验证 编辑:程序博客网 时间:2024/05/16 10:14

在jquery中绑定多个事件名称是,使用空格隔开,举例如下

$("#foo").bind("mouseenter mouseleave",function()){

$(this).toggleClass("entered");

});

在1.4版本之后,也可以这样绑定

     $("#foo").bind({
             focusin:function(){
                 if($(this).val() =="请输入电话/公司/姓名搜索"){  
                        $(this).val("");
                    }
             },
             focusout:function(){
                 if($(this).val() ==""){
                        $(this).val("请输入电话/公司/姓名搜索");
                   }
             }
         });

2.绑定一个元素的单事件

$("#foo").bind("click",function(){

$(this).slideToggle;

});

0 0
原创粉丝点击