0

What I have so far:

http://codepen.io/anon/pen/umHzl?editors=101

You notice that you can click a box and unclick it. What I would like is that when a certain button is clicked all other buttons are unclicked(turn back to normal color).

My attempt at this:

        for (var i =0; i < booths.length; i++){
                var obj = booths[i]
                obj.e1['fill'] = obj['color'];
                obj.e1['checked'] = 'false';
                $("#"+obj.name).remove();
            }

I know that the color is in the e1/rectangle object of the box, but I do not know how to change/access that variable. It says obj.e1 is undefined. If I do obj['fill'] it still doesn't work.

How would I change the colors from such a loop (or something similar).

1
  • You have an array of objects, not JSON. None of the objects has a e1 property, so what exactly did you expect obj.e1 to do? Commented Jun 26, 2014 at 1:19

1 Answer 1

1

It's not e1, it's el (lowercase 'L'). And you'll still want to use the attr() function, e.g.:

for (var i =0; i < booths.length; i++){
  var obj = booths[i]
  obj.el.attr('fill', obj['color']);
  obj.el.attr('checked', 'false');
  $("#"+obj.name).remove();
}

Example: http://codepen.io/paulroub/pen/yFwCq

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.