>

JavaScript的switch循环必发88官网

- 编辑:www.bifa688.com -

JavaScript的switch循环必发88官网

<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>

本文由必发88官网发布,转载请注明来源:JavaScript的switch循环必发88官网