bind(type,[data],fn)
type blur/focus/load/resize/scroll/unload/click/dblclick/
mousedown/mouseup/mousemove/mouseout/mouseenter/mouseleave/
change/select/submit/keydown/keypress/keyup/error
data event.data --fn(event) 传递给回调方法的event的data属性值
fn 回调方法
fn第一个参数是event对象,后面的参数取决于trigger带的参数。
$("p").click( function (event, a, b) { // when a normal click fires, a and b are undefined // for a trigger like below a refers to "foo" and b refers to "bar" } ).trigger("click", ["foo", "bar"]);
简写
click/mouseover/mouseout
$().ready()=$(function()) dom树加载完成调用
hover(overfn,outfn) 鼠标移入移出触发overfn,outfn
toggle(fn1,fn2,fn3) click依次触发fn1,fn2,fn3
unbind() 移除所有事件
unbind(type) 移除所有type事件
unbind(type,fnName) 移除指定type且方法名为fnName事件
one(type,fn)=bind(type,fn+unbind(fn)) 触发一次后自动移除事件
one(type,fn)=bind(type,var fnName=funciton(){ fn(); $(this).unbind(type,fnName); })
trigger(type,args)......click(type,fn(event,args)) 触发事件
triggerHandler(type) 不触发流浪器默认事件
event.stopPropagation() 阻止冒泡
event.preventDefault() 阻止默认行为(url跳转,表单submit)
简写:return false
event.type、event.target、event.pageX/pageY
bind("click.plugin") 绑定click事件,定义命名空间为plugin
unbind(".plugin") 解除plugin命名空间下的绑定事件
trigger("click!") 只触发没有命名空间的绑定事件