1

How can I use a string variable as an object name in jQuery?

var elem = "objectName";

...to be used in a similar fashion to...

var opts = $.nt.elem.options;

I tried var opts = $.nt[elem]options; to no avail.

Any ideas?

Jon
  • 3,154
  • 13
  • 53
  • 96

1 Answers1

2

You've missed a dot in var opts = $.nt[elem].options;

Oleksii Artiukh
  • 384
  • 1
  • 9
  • Ah. Good catch. I tried dots on both sides, but not just on the right. Thank you! – Jon Sep 02 '15 at 19:35