jQuery EventModule:jQuery目前支持的相关事件

吕的部落格唯女子与小人为难养也近之则不孙远之则怨

jQuery EventModule

jquery目前支持的相关事件

EventModule

, otherwise $(document).ready() may not fire.

Examples

  $(document).ready(function(){
// Your code here...
});

hover(Function, Function)

Parameters

FunctionA Javascript function
FunctionA Javascript function

Description

This is a custom method which provides an 'in' to a frequent task. Whenever the mouse cursor is moved over a matched element, the first function is fired.

Whenever the mouse moves off of the element, the second function fires. On top of this, checks are in place to see if the mouse is still within the element itself (for example, an image inside of a div), and if it is, it will continue to 'hover', and not move out (a common error in Javascript code).

Examples

  $("p").hover(function(){
this.$old = this.innerHTML;
$(this).html("Welcome!");
},function(){
$(this).html(this.$old);
});

toggle(Function, Function)

Parameters

FunctionA Javascript function
FunctionA Javascript function

Description

Whenever a matched element is clicked, the first function is fired, when clicked again, the second is fired. All subsequent clicks continue to rotate through the two functions.

Examples

  $("p").toggle(function(){
$(this).addClass("selected");
},function(){
$(this).removeClass("selected");
});

Dynamic event(Function)

Parameters

FunctionA Javascript function

Description

Shortcuts for using the bind and unbind functions are provided, where you would normally type:

  $("p").bind("click",Function);

you can now type:

  $("p").click(Function);

This is included for all of the following events

  • abort
  • blur
  • change
  • click
  • contextmenu
  • dblclick
  • error
  • focus
  • keydown
  • keypress
  • keyup
  • load
  • mousedown
  • mouseenter (Internet Explorer only)
  • mouseleave (Internet Explorer only)
  • mousemove
  • mouseout
  • mouseover
  • mouseup
  • reset
  • resize
  • scroll
  • select
  • submit
  • unload

Dynamic unEvent(Function)

Parameters

FunctionA Javascript function

Description

This is a shortcut, similar to the previous one, but for detaching a Function from a matched element.

Examples

  $("p").unclick(Function);

Also, you can leave the function empty and completely remove all of a particular event type. For example, the code below removes all click events from the element.

  $("p").unclick();

Dynamic oneEvent(Function)

Parameters

FunctionA Javascript function

Description

This is another shortcut, following the same rules as 'onclick, etc.', but will only fire once. This is very useful for buttons, links, etc.

Examples

  $("p").oneclick(function(){
alert("Only once!");
});
link:http://jquery.com/docs/EventModule/
所属分类:技术手册标签:jQueryAjax jQueryEventModul 吕 @ 2006年10月29日10点51分 AM 编辑 jQuery EventModule阅读(2212) 评论(0)

相关文章

评论

还没有评论
未开放评论

谷歌中jQuery EventModule相关文章

数据加载中,请稍候……