Questions tagged [jquery-on]

jquery on method can be used to bind events on dom elements. It also supports event delegation.

jQuery .on() attach an event handler function for one or more events to the selected elements. docs

$("selector").on( events [, selector ] [, data ], handler )

The .on() method attaches event handlers to the currently selected set of elements in the jQuery object. As of jQuery 1.7, the .on() method provides all functionality required for attaching event handlers.

Examples

// Example 1
$("div").on("click", function(){
  // do something
});
// Example 2
function notify() {
  // do something
}
$("button").on("click", notify);
// Example 3
$("input").on("keyup keydown", function(){
  // do something
});

Resource

166 questions
0
votes
1 answer

Turning an animation event on and off with Jquery

I need help. I am able to turn an event on with the click of a button, but can't figure out how to turn it off with another click of that same button. Also, I can't seem to get the animation speed and easing to work. Any suggestions? (I'm learning…
Amanda C.
  • 1
  • 1
0
votes
1 answer

Bug with jquery .on and facebox

I have an element that loads from AJAX. With tthat element, I attached Facebox.js. When the element is clicked, it will triggered Facebox. So I used: $(document).on("click", "a[rel*=modal]", function() { $(this).facebox(); // Applies modal…
Erwin Kaddy
  • 967
  • 7
  • 14
0
votes
2 answers

how to attach hover handler to TD elements, filtering on a class selector that may be applied in the future

My table will have a number of TD elements that get assigned a class, .foo, during the course of the user working with the data. The table might have a few hundred cells and only a dozen of those may acquire the .foo class. I want to listen for…
Tim
  • 8,669
  • 31
  • 105
  • 183
0
votes
3 answers

Javascript - On('Click') - Error - Calling On Page Load