• JavaScript的switch循环


    <html>
    <head>
    <meta charset="utf-8">
    <title>无标题文档</title>
    <style type="text/css">
        #div1 {
            width: 200px;
            height: 50px;
            border: 1px solid red;
        }
    </style>
    </head>
    
    <body>
    姓名:<input type="text" id="txt1" />
    性别:<input type="text" id="txt2" />
    &nbsp;<input type="button" id="btn1" value="提交" />
    <br>
    <br>
    <div id="div1"></div>
    <script>
        var otxt1=document.getElementById('txt1');
        var otxt2=document.getElementById('txt2');
        var odiv1=document.getElementById('div1');
        var obtn1=document.getElementById('btn1');
        var n1=otxt1.value;
        var n2=otxt2.value;
        var d1=odiv1.innerHTML;
        obtn1.onclick=function()
        {
            switch(n2)
            {
            case '':
            alert('n1+'先生,您好');
            break;
            
            case '':
            d1='n1+'女士,您好';
            break;
            
            default:
            d1='n1+'您好';
            break;
            }
        }
    </script>
    </body>
    </html>
  • 相关阅读:
    Currency Exchange
    Robot Motion
    Crashing Robots
    Parencodings
    Y2K Accounting Bug
    Tautology
    Power of Cryptography
    Radar Installation -poj 1328
    The Pilots Brothers' refrigerator
    【java】之cron表达式
  • 原文地址:https://www.cnblogs.com/xinlvtian/p/7892260.html
Copyright © 2020-2023  润新知