Monday, 15 July 2013

asp.net - Adding On() event instead of live() event in Jquery -



asp.net - Adding On() event instead of live() event in Jquery -

i'm bit confused right now, before changed jquery 1.9.1 used live() event bind events buttons on document.ready, forced alter .live() .on() event, , buttons stopped working. code had before :

$(document).ready(function () { $("#button").live('click', buttonevent); });

and after:

$(document).ready(function () { $("#button").on('click', buttonevent); });

what missing?

$(document).ready(function () { $(document).on('click', '#button', buttonevent); });

jquery .on() can used delegate events on elements. pattern bit differrent better.

jquery asp.net

No comments:

Post a Comment