I'm trying to make a simple jQuery accordion plugin and can't figure out why doesn't the 'this' keyword work as it should. Here's the code of the plugin:
(function( $ ){
$.fn.accrdn = function(userSettings) {
var defaults = {
toggle: true
};
var options = $.extend({}, defaults, userSettings);
var handle = this.find('.handle');//doesn't work!
if (options.toggle) {
handle.click(function(){
$(this).next('.panel').slideToggle();
});
} else {
handle.click(function(){
$(this).next('.panel').slideUp();
});
};
};
})( jQuery );