<script type='text/javascript'>
function redirect() {
var input = document.getElementById('userInput').value;
switch(input) {
case 'ALCOA':
window.location.replace('alcoa-Forms.htm');
break;
case 'alcoa':
window.location.replace('/alcoa-Forms.htm');
break;
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能让这个函数不区分大小写,所以我只能写一次?
最简单的方法是使输入全部为大写或全部为小写.拿你的选择:
input = input.toUpperCase();
switch (input) {
case 'ALCOA':
...
Run Code Online (Sandbox Code Playgroud)
请记住,这也将为其工作Alcoa,aLcOa等等.
你也可以写case两次:
switch (input) {
case 'ALCOA':
case 'alcoa':
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3534 次 |
| 最近记录: |