
November 13th, 2012, 09:13 PM
|
|
Contributing User
|
|
Join Date: May 2005
Posts: 43
Time spent in forums: 8 h 16 m 2 sec
Reputation Power: 9
|
|
|
jQuery - Custom event question
Hi
What i'm trying to do is to create a custom event. Here is the code snippet
Code:
jQuery.fn.extend({
myclick: function (fn) {
$(this).bind(click,function(e){
fn.call(this, e);
})
});
I've managed to get it to work by the following
Code:
$('div').myclick(function(e){alert(e)})
but cant seem to get it to work with
Code:
$('div').bind('myclick',function(e){alert(e)})
How do i get the .bind to work in this scenario?
Sorry if this is an easy question. I'm new to JS
Thank you in advance
|