I know that you can add new jQuery functions by $.fn.someFunction = function()
$.fn.someFunction = function()
However, I want to add functions to specific elements only. I tried this
yo can do the above with this:
$.fn.testFn = function(){ this.each(function(){ var className = $(this).attr('class'); $(this).html(className); }); }; $('li').testFn(); //or any element you want
Test: http://jsfiddle.net/DarkThrone/nUzJN/