我不确定这是可能的,但是,有没有办法选择一个与字符串同名的对象,并在 .each 循环中使用它?
var test = "myobj";
var myobj = {"1" : "2", "2" : "3"};
function testing(test){
// If i do a console.log on the variale "test":
console.log(test); // will show the string: "myobj"
typeof(test); // is string
// somehow select the object with the name myobj, and maybe iterate through it?
jQuery.each(myobj, function(key, val){
alert(val); // right now this will alert the actual letters: m y o b j
});
}