0

I'm trying to construct global vars inside of jQ .each(). I get 'invalid left-hand side in assignment' error...

'prefix_' + $(this).attr('id') = $(this).method();

1 Answer 1

2
window['prefix_' + $(this).attr('id')] = $(this).method();
Sign up to request clarification or add additional context in comments.

2 Comments

one question, if I want to then push that var into an array, how do I reference it? myArray.push(window['prefix_' + $(this).attr('id')]); ...?
Yep, that should do it.

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.