1

I need to do something like this:

$('#online-order').wcForms({id: '#online-order', to: 'contact', colors['red']: '#00F' });

But there is mistake in syntax. Please, tell me how i must pass it. Thanks!

1
  • Mistake is there, colors['red']: '#00F' its esey, but how it looks in right syntax :) Commented Jul 1, 2011 at 11:33

1 Answer 1

3

As Javascript has no associative arrays, if you want it that way, you need to use another object.

{id: '#online-order', to: 'contact', colors: { red: '#00F'} }

jsFiddle Demo

You can access your red property like this:

var obj = {id: '#online-order', to: 'contact', colors: { red: '#00F'} };

console.log(obj.colors.red);
//or
console.log(obj['colors']['red']);
Sign up to request clarification or add additional context in comments.

3 Comments

so, i've reach this by myself already. But whenever, thanks you a lot for focus.
@Ax Hm, then what is your question exactly?
No question, already. I just can't close this post before last a few minuts.

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.