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
4 answers

jQuery doesn't recognize :not(.className) filtering

When I dynamically add a class to an element, pseudo filtering doesn't recognize that class. This problem occurs when I use on() function, but everything is fine when I use live() http://jsfiddle.net/AHyyq/1/ At the beginning, all list items are…
user472268
0
votes
1 answer

How do I use jQuery .on() to handle click event for a newly inserted dialog link?

I have an existing link to a jQuery dialog that works as it should. But when I try to insert a new dialog link, using .on() to select an existing div, the link does not produce the dialog, but rather simply links to the page. Can someone help to…
aaron
  • 1
  • 2
0
votes
3 answers

How to check which elements are being targeted from .on with jQuery

I am unsure which elements are being targeted within my .on $('.levelFour').on('mouseover','> li',function(m){ I wonder, is there a way to display which elements are being targeted?
Jamie Hutber
  • 26,790
  • 46
  • 179
  • 291
0
votes
0 answers

jQuery Sortable freezes after AJAX html replace

jQuery Code: I removed all my Sortable settings. If you feel they are pertinent I can put them back in. $('#navsort').sortable({ ... }); $("#content").on('click', '#submit_menu', function (event){ event.preventDefault(); $.ajax({ …
Kirkland
  • 2,319
  • 4
  • 20
  • 27
0
votes
2 answers

How to bind an iframe with 'on' method in jquery?

Bind an iframe with on method in jquery. I am using jquery mobile lib with an iframe in page. $(frame).contents().on('tap', 'div', function() { console.info('sucess')} )} How to bind the iframe with on method? Here I tried to get tap function bind…
Justin John
  • 9,223
  • 14
  • 70
  • 129
0
votes
1 answer

How significant is the order with jQuery's trigger-method?

I want to provide a way to use an on-event handler from the outside of a plugin. Problem is, that the trigger will not fired if I provide them in wrong order. For example, this works: $(window).on('foo:bar', function(){ …
yckart
  • 32,460
  • 9
  • 122
  • 129
0
votes
2 answers

jQuery on() method with click and element class name triggerred anywhere on the page

Recently I've upgraded jQuery to 1.9 and my main problem now is to convert all live() methods to on(). I've succeeded in a few situation, but I have some other methods that just behave very strange. Take the following as an…
Spencer Mark
  • 5,263
  • 9
  • 29
  • 58
0
votes
2 answers

jQuery event delegation in 1.7.2

Is there any way to delegate an event using jQuery that will correspond to all elements on the page that match the selector, other than delegating from $(document)? Since that's probably poorly worded, here's the rub: There used to be jQuery.live…
Thomas Jones
  • 4,892
  • 26
  • 34
0
votes
3 answers

Storing multiple selectors in a single variable

I have a piece of code that handles clicks on images that represent buttons. If that image is clicked, its corresponding image will appear to the user. By selecting the multiple IDs of the images, the vode below works perfectly…
Navigatron
  • 2,065
  • 6
  • 32
  • 61
0
votes
1 answer

How to use jquery .on() with jquery plugins(for eg with hoverpulse)?

I am trying using .on() with hoverpulse plugin for applying it to dynamically loaded contents but not getting a way out. It will be very kind if someone can help. Thanks in advance. JQUERY CODE TO CALL HOVERPULSE…
Abhinav
  • 961
  • 2
  • 11
  • 17
0
votes
4 answers

jQuery hover effect not working

I have dynamically generated div tags which looks something like this:
oshirowanen
  • 15,297
  • 82
  • 198
  • 350
0
votes
2 answers

How do I trigger a function to execute after external HTML is loaded?

JS: $(document).ready(function(){ $("#loader").load("external.html"); $("#buttonClickText").live('click', function() { $("#buttonClickText").text("Text changed after button click."); }); // MYSTERY FUNCTION …
Orb Hitter
  • 317
  • 1
  • 4
  • 9
0
votes
1 answer

Jquery On and Live Confusion

Look at these example codes: We have ​
​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ And we have jquery code; 1-With On $('.ex').append("
object-1
"); $('.text').on({ hover:…
mausmust
  • 105
  • 1
  • 1
  • 7
0
votes
2 answers

On and Live behave differently on dynamic addition of elements

I am having the following code, i tried with jQuery live and on plugin, while trying with live, i am able to add the event handler which is already present for the element with the class "button" to the newly added element(added dynamically after…
Mohamed Hussain
  • 7,433
  • 14
  • 55
  • 85
0
votes
2 answers

Jquery best performance on (live) vs on (bind)

I have a question about the performance of on use as the former live and on use as the former bind. My question is what is the better choice in terms of performances if we have to create multiple (let's say hundreds) elements in the dom and add an…
guts
  • 381
  • 1
  • 9
  • 22