0
Я возвращаю строку направления для функции, и я хочу заменить свойство left
для jquery animate со строкой в возвращаемом значении.Использование строки данных как свойства в jquery animate
я попытался следующие, не работал
// my attempt at using string returned for property
function direction (data) {
// move the object in the direction given by x
$("#cube").animate({
data.direction: "+=5" // here changed from left -> data.direction which has the direction string inside [left up right down]
}, 10, function() {
// Animation complete.
});
}
// original working example
function direction (data) {
// move the object in the direction given by x
$("#cube").animate({
left: "+=5"
}, 10, function() {
// Animation complete.
});
}