Почему при помощи if работает:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Выбор</title>
</head>
<body id="0">
<input type="button" value="1" id="decis1" onclick="numb(1);">
<input type="button" value="2" id="decis2" onclick="numb(2);">
<script>
function numb(decis) {
if (curScene == 0) {
if (decis == 1) {
alert("hello1")
}
else {
alert("hello2")
}
}
}
var curScene = document.getElementById("0").id;
</script>
</body>
</html>
А при switch нет?
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Выбор</title>
</head>
<body id="0">
<input type="button" value="1" id="decis1" onclick="numb(1);">
<input type="button" value="2" id="decis2" onclick="numb(2);">
<script>
function numb(decis) {
switch (curScene) {
case 0:
if (decis == 1) {
alert("hello1")
}
else {
alert("hello2")
}
break;
}
}
var curScene = document.getElementById("0").id;
</script>
</body>
</html>