Adding a class to an element in a plugin I have the following code, and I just added a Class to the element that uses the plugin. I works perfectly, but I am wondering if there is a better way to do it.

(function ($) {

/**
 * jQuery Plugin Extension
 */
$.fn.extend({

    /**
     * build editable
     *
     * @param {string} saveUrl
     * @param {Object} options
     * @returns {*}
     */
    baseEditable: function (saveUrl, options) {

        var settings = $.extend(true, {
            name: 'value',
            onblur: 'submit',
            placeholder: $.i18n._('msg_click_to_add'),
            ajaxoptions: {
                dataType: 'json'
            }
        }, options);

        return this.each(function () {
            $(this).addClass('editable');
            var baseEditable = $(this).editable(saveUrl, settings);

            $(this).data('baseEditable', baseEditable);
        });

    }
});
})(jQuery);
You can use the addClass method on all the elements instead of creating a new jQuery object for each item:

return this.addClass('editable').each(function () {
  var baseEditable = $(this).editable(saveUrl, settings);
  $(this).data('baseEditable', baseEditable);
});