Jquery 动画不工作但 运行 控制台
Jquery Animate not working but run console
抱歉,我不会说英语,请原谅。我有对象 'window.userInterface.filmMakinesi'。我这个对象运行控制台没问题。但是当 运行 我的 javascript 文件创建时出现问题。不工作。有意思。
window.userInterface.filmMakinesi = function(control) {
controlBox = [];
controlBox["ileri"] = {dinamikCSS: "top",operator:"-"};
controlBox["geri"] = {dinamikCSS: "bottom",operator:"+"};
secim = controlBox[control].dinamikCSS;
operator = controlBox[control].operator;
height = parseInt($("section.open").height());
/*
secim : top;
operator: -
height: 270;
*/
$("div#filmMakinesi").animate({ secim : operator+height+"px"},600,"swing");
}
window.userInterface.filmMakinesi("geri");
不工作,但它是如何工作的。字符串而不是尝试我写了值。
window.userInterface.filmMakinesi = function(control) {
controlBox = [];
controlBox["ileri"] = {dinamikCSS: "top",operator:"-"};
controlBox["geri"] = {dinamikCSS: "bottom",operator:"+"};
secim = controlBox[control].dinamikCSS;
operator = controlBox[control].operator;
height = parseInt($("section.open").height());
// \/\/\/
$("div#filmMakinesi").animate({ "top" : operator+height+"px"},600,"swing");
}
window.userInterface.filmMakinesi("geri");
您将需要创建一个对象,以便您可以使用 []
符号来允许使用变量 secim
作为动态变量 属性。
var animateObject = {};
animateObject[secim] = operator+height+"px";
$("div#filmMakinesi").animate(animateObject ,600,"swing");
您不能这样创建 属性 foo
:
var myVariable = 'foo';
var object = { myVariable :'some value'};
console.log(object.foo) // returns undefined
console.log(object.myVariable ) // returns 'some value'
抱歉,我不会说英语,请原谅。我有对象 'window.userInterface.filmMakinesi'。我这个对象运行控制台没问题。但是当 运行 我的 javascript 文件创建时出现问题。不工作。有意思。
window.userInterface.filmMakinesi = function(control) {
controlBox = [];
controlBox["ileri"] = {dinamikCSS: "top",operator:"-"};
controlBox["geri"] = {dinamikCSS: "bottom",operator:"+"};
secim = controlBox[control].dinamikCSS;
operator = controlBox[control].operator;
height = parseInt($("section.open").height());
/*
secim : top;
operator: -
height: 270;
*/
$("div#filmMakinesi").animate({ secim : operator+height+"px"},600,"swing");
}
window.userInterface.filmMakinesi("geri");
不工作,但它是如何工作的。字符串而不是尝试我写了值。
window.userInterface.filmMakinesi = function(control) {
controlBox = [];
controlBox["ileri"] = {dinamikCSS: "top",operator:"-"};
controlBox["geri"] = {dinamikCSS: "bottom",operator:"+"};
secim = controlBox[control].dinamikCSS;
operator = controlBox[control].operator;
height = parseInt($("section.open").height());
// \/\/\/
$("div#filmMakinesi").animate({ "top" : operator+height+"px"},600,"swing");
}
window.userInterface.filmMakinesi("geri");
您将需要创建一个对象,以便您可以使用 []
符号来允许使用变量 secim
作为动态变量 属性。
var animateObject = {};
animateObject[secim] = operator+height+"px";
$("div#filmMakinesi").animate(animateObject ,600,"swing");
您不能这样创建 属性 foo
:
var myVariable = 'foo';
var object = { myVariable :'some value'};
console.log(object.foo) // returns undefined
console.log(object.myVariable ) // returns 'some value'