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
Alec Smart
96.2k39 gold badges125 silver badges188 bronze badges
-
presumably there is a function called "c" that is a property of temp?Russ Cam– Russ Cam2009年09月21日 10:26:44 +00:00Commented Sep 21, 2009 at 10:26
1 Answer 1
You can use the brackets instead of the dot notation:
var temp = 'b';
$.a[temp].c();
answered Sep 21, 2009 at 10:25
googletorp
33.3k15 gold badges69 silver badges82 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js