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
Post a Comment