Jquery bind

来源:互联网 发布:算法实战 编辑:程序博客网 时间:2024/06/06 05:10

bind使用:

bind() 方法为被选元素添加一个或多个事件处理程序,并规定事件发生时运行的函数。

语法:

$(selector).bind(event,data,function)

1、

$(document).ready(function(){  $("button").bind({    click:function(){$("p").slideToggle();},    mouseover:function(){$("body").css("background-color","red");},      mouseout:function(){$("body").css("background-color","#FFFFFF");}    });});


2、

$("button").bind("click",function(){  $("p").slideToggle();});

call 和 Apply

    var Func1 = function (name) { alert(name); };
    Func1.call(this,"hello new year");
    //Func1.apply(this, ['hello new year','DBLL']);