switch练习
switch练习
<div> <label for="id">ID号</label> <input type="text" id="id" name="id"> <button id="submit">查询</button> </div> <div id="reveal"></div> <script> var id=document.getElementById('id'); var submit=document.getElementById('submit') submit.addEventListener('click',test); function test(ev){ var s=(id.value)/1; var x; var re=document.getElementById('reveal'); console.log(typeof(s)); switch(s){ case 1:re.innerHTML='这是第一个'; break; case 2:re.innerHTML='这是第二个'; break; default: re.innerHTML='8888888888'; } } </script>