Grow your CSS skills. Land your dream job.

Quick question about jQuery plugin settings?

  • # November 14, 2012 at 5:14 pm

    Im having trouble calling my speed for my plugin. The code following is not the extent of my plugin, it is just for testing.
    Basic Plugin:

    (function($) {

    $.fn.colorspan = function(options) {
    var settings = {
    speed: 800
    };

    if (options) {
    $.extend(settings, options);
    }

    function testFunction() {
    $('div').append("Howdy folks
    ");
    }

    timer = setInterval(function() {
    testFunction();
    }, settings.speed);
    };
    })(jQuery);

    This works:

    $('div').colorspan();

    This doesn’t work:

    $('div').colorspan(speed:'100');

    Test Case: http://jsfiddle.net/john_motyl/yETC3/

    # November 14, 2012 at 5:30 pm

    You were *very* close ;)

    http://jsfiddle.net/yETC3/1/

    # November 14, 2012 at 7:01 pm

    @The Doc = FOR THE WIN!

    Thanks man, i dont know how i forgot that.

    # November 14, 2012 at 7:15 pm

    If JSfiddle ever dies and somebody wants to know, this is all that needed to be changed:

    $(‘div’).colorspan({ speed:’100′ });

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".