1

My jQuery function is something like:

$.a.b.c();

Now I am trying to call it dynamically:

var temp = b;
$.a.temp.c();

But obviously its not working. How do I get this to work. Please feel free to edit the question title, as am not sure how to really phrase the question.

asked Sep 21, 2009 at 10:22
1
  • presumably there is a function called "c" that is a property of temp? Commented Sep 21, 2009 at 10:26

1 Answer 1

3

You can use the brackets instead of the dot notation:

var temp = 'b';
$.a[temp].c();
answered Sep 21, 2009 at 10:25
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.