javascript - Very simple jquery custom function throws error -


i have following code:

$(document).ready(function() {     $.fn.addremovebutton = function() {         alert(1);     };      $.addremovebutton(); }); 

and following error message firebug:

typeerror: $.addremovebutton not function $.addremovebutton();

why , how can fix this?

you need define selector, try this:

$(document).ready(function() {     $.fn.addremovebutton = function() {         alert(1);     };      $(document).addremovebutton(); }); 

here working jsfiddle.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -