html 中使用prompt让用户输入两个数,求最大值和最小值

如题所述

<input type="button" onclick="disp_prompt()" value="点击输入两个数" />
<script type="text/javascript">
function disp_prompt()
{
var name=prompt("输入两个数","比如:5^7")
var tot = name.split("^");
var max="";
var min="";

if(tot[0] > tot[1]){
max = tot[0];
min = tot[1];
}else{
max = tot[1];
min = tot[0];
}

document.write ('最大数:'+max+'/'+'最小数:'+min);

}
</script>
超简单 型
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网