我的 JS 有问题,每当我在脚本标签中写“\n”时,它不会打印新行。我是 Javascript 新手,所以有人可以向我解释问题是什么吗?
这是我练习的代码:
<html>
<head>
<meta charset="utf-8">
<script>
var output;
var number = window.prompt("Enter mobile no: \n");
if( number>10000000 && number<99999999){
var ps = parseInt(number/1000000);
var vs = parseInt((number/1000)%1000);
var ts = number%1000;
output = "0" + ps + "/" + vs + "-" + ts +" ";
document.write("Mobile no. is : " + output + " " + "\n");
if( ps == 70 || ps == 71 || ps == 72 ){
document.write("Mobile no. is T-Mobile " + "\n");
}
if( ps == 75 || ps == 76){
document.write("Mobile no. is One " + "\n");
}
if( ps == 77 || ps == 78){
document.write("Mobile no. is Vip " + "\n");
}
}
</script>
</head>
<body>
//not important
</body>
</html>