<input type="text" id="txt"/> <input type="button" value="点击" id="btn"/> <script> /*输入月份,显示当月的天数*/ btn.onclick = function(){ var month = txt.value; switch(month){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: console.log(‘本月为31天‘); break; case 2: console.log(‘本月为28天‘); break; case 4: case 6: case 9: case 11: console.log(‘本月为30天‘); break; default: alert(‘宝贝你输入错误了‘) } } </script>
时间: 2024-09-30 06:51:59