It is possible to use a variable as a value:
$("#anything").css({
"top": value
});
But if I try the opposite:
toporbottom = "top";
$("anything").css({
toporbottom: "50px"
});
it doesnt work. Is there a elegant solution?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In your case, you don’t need an object because you’re only setting one property. Use:
If you do want an object, you’ll have to make an empty one first, then set the property using the
[...]notation, and passobj. But this is definitely overkill here: