Grow your CSS skills. Land your dream job.

Tryint to create the index of a constructor

  • # March 3, 2012 at 2:27 am
    function Category(year, min, max) {
    this.count = year;
    this.min = min;
    this.max = max;
    }
    var mazda = new Category(1995, 0, 12),
    honda = new Category(1998, 0, 14);

    What’d i’d like is to be able to call an index of Category. So Category[0] could yield (1995,0,12). Any ideas?

    # March 3, 2012 at 5:09 am

    I think I’m totally lost
    But is this what you mean?

    http://jsfiddle.net/c8K7D/

    # March 3, 2012 at 8:23 pm

    Thanks so much for your speedy reply. I think that might help, but I should have explained in more detail. I’m trying to make this bit of code more flexible. I’ve set up a div with two buttons and a span holding counter.





    What’d I’d like to do is have the javascript flexible enough, that no matter how many button counter structures one add, the javascript could identify which button was clicked and the count up or down and update the span.

    *Oh and so that each button/counter structure could have it’s own set of min/max values where one the value is reached the button is disabled

    You can see how I’ve set it up currently at: http://jsfiddle.net/mhumeSF/vJrpE/17/

    # March 3, 2012 at 8:41 pm

    Found a solution: http://css-tricks.com/number-increment-buttons/

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".