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

相关文章:

  • 2021-12-22
  • 2022-01-10
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-07
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案