Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

jQuery provides a bind function which allows us to add an event handler to an HTML element. The bind function consists of three parts. First you specify a CSS selector which selects the HTML elements to perform the bind operation on. In this example the CSS selector is the ID of the link we want to bind to -> '#mylink' (The hash (#) prefix denotes a CSS ID selector). Then you specify which event to bind to. In the example above this is the 'click' event. Lastly you specify the function to invoke when the event is triggered. (jQuery's bind is synonymous to JavaScript's addEventListener (attachEvent in IE). Another way to bind is to specify the event handler as an HTML element attribute (<a onclick="success" href="...">Click me!</a>))

...

$('#mylink').bind('click', clickFunction(event)
$('#mylink#mybutton').bind('hoverclick', hoverFunctionclickFunction(event)

or one HTML element to multiple events:

$('#mybutton#mylink').bind('click', clickFunction(event)
$('#mylink').bind('hover', hoverFunction(event)

So from From Click's perspective, it needs to render this bind statement along with the JavaScript function that will be invoked when the event is performed.

...