jQuery: The Write Less, Do More JavaScript Library

Error: Failed to load processor NavWiki
No macro or processor named 'NavWiki' found

This code is part of the the jQuery Base? module.

Events

bind(Event,Function)

Error: Failed to load processor param
No macro or processor named 'param' found

Description

Attaches the specified function to all the matched objects for the 'String' event.

Examples

  $("p").bind("click",function(){
    alert("Hello!");
  });

Notes

The function that is attached to the event is passed one parameter: The event object. You can use it to perform further event actions.

If you wish to cancel a default action and stop the event from bubbling, return false from your function, for example:

  $("form").bind("submit",function(){
    return false;
  });

To stop the default action OR to stop the event from bubbling, use these methods:

  $("form").submit(function(e){
    e.preventDefault(); // Stop form submission
  });
  $("form").submit(function(e){
    e.stopPropagation(); // Stop event bubbling
  });

unbind(Event,Function)

Error: Failed to load processor param
No macro or processor named 'param' found

Description

Unattaches the specified function from all the matched objects for the 'Event'. Remove all event handlers by omiting the first parameter; remove all event handlers for a specified event by not providing the second parameter.

Examples

  var b = function(){ alert("Hello!"); };
  var c = function(){ alert("Goodbye!"); };
  $("h3").bind("click",b);
  $("h3").bind("dblclick",c);
  $("h3").unbind("click",b);
  $("h3").unbind("dblclick");   //remove dblclick event
  $("h3").unbind("click,dblclick");   //remove all event handlers