Passing function literal via event
Am I able to pass a function literal (at least I think that's what it's called) to a jquery event handler, and retrieved the event details in the function?
Like so:
- function doSomething(ev)
- {
- alert(ev);
- }
- $(someElement).click(doSomething);
I think that's more efficient that the following, when registering events on a large number of elements, or am I wrong?:
- $(someElement).click(function()
- {
- doSomething($(this));
- });