I am wondering how to chain my custom functions and maintain context of 'this'.
Example:
$.fn.foo = function() {
var html = '<div class="foo"></div>';
if ($(this).hasClass(somthing) {
$(this).prepend(html);
}
}
$.fn.bar = function() {
var html = '<h3>bar</h3>';
$(this).find('.foo').prepend(html);
}
$('body').foo().bar();
When i try to use this code i get a TypeError: Cannot read property 'bar' of undefined