javascript - Wrap existing jquery event with defaults -


I am trying to figure out how I will wrap the click event. The example is that I want the code to be.

  $ ("#search"). Aclick (function () {alert ('hi');});   

Eclipse does only one thing use e.preventDefault automatically Is there something like this?

  $ Fn.aclick = function (e) {e.preventDefault (); $ .fn.click.apply Return (this, argument); });   

Thanks.

When binding is a handler, event object e Does not exist yet You need to create a default event handler that calls the supplied call:

  $ .fn.aclick = function (handler) {return.Each ( Function () {var el = this; $ (L). Click (function (e) {e.preventDefault (); handler call (L, E);});}); };    

Comments