0

I have a defined namespace: Cookies and under it ShowLabels and ShowOptions

I want to be able to call the namespace on page using a jquery val assuming it will either return ShowLabels or ShowOptions IE:

Cookies.$.trim($(this).val())

How can I do this?

2
  • As per my understanding Cookies is your object and you have ShowLabels & ShowOptions as your methods ? Commented Aug 15, 2013 at 16:12
  • I don't suppose it matters but in this case they are properties. Commented Aug 15, 2013 at 16:13

1 Answer 1

3

Use square brackets to access a property by a string name:

Cookies[$.trim($(this).val())]
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.