jQuery Help Needed

Hello everyon,

I have a small jQuery related task to complete, and keep failing to do so, unfortunately. I need to output the value of a custom defined variable, as follows:

$(document).ready(function()
{
	$('#preFeature').siteFeature({
                outputElementId: 'CustomSliderName',
	});
	return false;
});

Below is the code to replace the default value with the custom defined one:

(function ($) {
    $.fn.siteFeature = function (b) {
        var c = $.extend({}, $.fn.siteFeature.defaults, b);
        return this.each(function (i) {
            obj = $(this);
            var a = {};
            a.which = i;
            createFeature(c, a);
            customizeFeature(c, a);
            eventFeature(c, a)
        })
    };
    $.fn.siteFeature.defaults = {
        outputElementId: 'siteFeature',
    };
})(jQuery);

function siteFeatureAutoPlayer(a)
{
    var defaultSliderId = jQuery.fn.siteFeature.defaults.outputElementId; // this defines the default ID, works well
    var sliderID = [COLOR="#FF0000"]jQuery.fn.siteFeature.......outputElementId[/COLOR]; // need to fix this part
}

I can’t figure out how to call the outputElementId variable in a function outside the jQuery class (see the red highlighted text). Could someone tell me the right way to do it, that would be much appreciated, thanks!

I’d probably have to question why you would need to access the value of your default options outside of the plugin block.

The idea of the default options that you can extend is that they are reasonably sane defaults set by the plugin that should not be changeable from the outside, but you can override them by passing in new values.

I’d also recommend using clear variable names, “a”, “b” and “c” aren’t the most descriptive names.

For more info on writing jQuery plugin code see:

I found a solution, thanks!