for (var i = 1; i <= 4; i++) {
for (var j = 5; j <= 16; j++) {
if ("tp'+i+'" == "tp'+j+'" && "lft'+i+'" == "lft'+j+'") {
if ('k' + j == 0) {
"tp'+j+'" = $('#circle' + j).css("top"); "lft'+j+'" = $('#circle' + j).css("left");
document.getElementById('circle' + j).style.left = 'lft' + j + "px";
document.getElementById('circle' + j).style.top = 'tp' + j + "px"
}
}
}"k'+i+'" = 0;
}
以下是我用于在if语句中组合字符串和数字的代码,但它没有发生,有人能告诉我什么是错的以及如何做到这一点?
答案 0 :(得分:0)
也许您必须将num转换为String:
例如:
if (("tp" + i.toString() == "tp"+ j.toString()) && ("lft" + i.toString() == "lft" + j.toString()))