Fer*_*SBS 8 javascript intervals switch-statement
我可以在switch语句中使用间隔吗?
喜欢
switch (parseInt(troops[i])) {
case <10:
editbox.style.fontSize = "13px";
break;
case <100:
editbox.style.fontSize = "12px";
break;
case <1000:
editbox.style.fontSize = "8px";
editbox.size = 3;
//editbox.style.width = "18px";
break;
default:
editbox.style.fontSize = "10px";
}
Run Code Online (Sandbox Code Playgroud)
???
Cah*_*hit 18
这应该工作:
var j = parseInt(troops[i]);
switch (true) {
case (j<10):
editbox.style.fontSize = "13px";
break;
case (j<100):
editbox.style.fontSize = "12px";
break;
case (j<1000):
editbox.style.fontSize = "8px";
editbox.size = 3;
//editbox.style.width = "18px";
break;
default:
editbox.style.fontSize = "10px";
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6531 次 |
| 最近记录: |