jquery - How to interpolate an object's key name in JavaScript/JSON? -


i have line of js:

overlay.animate({"left":"-1000px"}, "slow").removeclass('visible'); 

i need use variable (direction) instead of word "left", how can rewrite string?

this doesn't work:

overlay.animate({direction:"-1000px"}, "slow").removeclass('visible'); 

thanks

you need use [] access keys variable.

var options = {}; options[direction] = "-1000px"; overlay.animate(options, "slow").removeclass('visible'); 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -