$.fn.myfunction = function () {
console.log(this.length);
};
$('.foo').myfunction();
… will flush to the console the number of elements with the class foo.