Communities for your favorite technologies. Explore all Collectives
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
This is the example:
var side = 'left'; $('div').css({ position: 'relative', side: 50 });
I put variable side instead real property name. I was expecting that this will work, but... :)
side
So, how to set property name from varaibles value?
The only way is to declare previously your object as a variable...
var options = { position: 'relative' }; options[side] = 50; $('div').css(options);
Add a comment
50
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.