views:

52

answers:

1

Hello,

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.

+3  A: 

You can use the brackets instead of the dot notation:

var temp = 'b';
$.a[temp].c();
googletorp