Treehouse: Grow your CSS skills. Land your dream job.

[Solved] Can I loop through jquery plugin setting options?

  • # October 28, 2011 at 3:10 pm

    I’m sorry that the title might not be as descriptive as I want it to be

    I have jquery plugin with a couple settings like:

    option1: 3,
    option2: 8,
    option3: 5,

    I’ll try to simplify loop.

    for (i=1; i< =3; i++)
    console.log(settings.option + i);

    The issue I have is grabbing the setting value while using the ‘i’ from the loop. Any ideas on how I can loop through the settings and get their values?

    # October 28, 2011 at 5:24 pm

    Try doing this:

    console.log( settings["option" + i] );
    # October 28, 2011 at 5:59 pm

    Ah! perfect. Thank you. I was trying to figure out the syntax for it. Thanks a lot.

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

You must be logged in to reply to this topic.