当前第2页 返回上一页
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | <!DOCTYPE html>
<html>
<head>
<meta charset= "UTF-8" >
<title>Document</title>
</head>
<body>
<input type= "text" ><br>
<input type= "text" ><br>
<input type= "text" ><br>
<input type= "button" value= "确认" >
</body>
<script>
var inps = document.querySelectorAll( "input" );
inps[3].onclick = function (){
alert(Math.max(inps[0].value,inps[1].value,inps[2].value));
var a = Number(inps[0].value);
var b = Number(inps[1].value);
var c = Number(inps[2].value);
if (a>b){
if (a>c){
alert(a);
} else {
alert(c);
}
} else {
if (b>c){
alert(b);
} else {
alert(c);
}
}
if (a>=b && a>=c){
alert(a);
}
if (b>=a && b>=c){
alert(b);
}
if (c>=a && c>=b){
alert(c);
}
var max = 0;
if (a >= max){
max = a;
}
if (b >= max){
max = b;
}
if (c >= max){
max = c;
}
alert(max);
}
</script>
</html>
|
推荐学习:《javascript高级教程》
以上就是javascript怎么求三个数的最大值的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
javascript中定义函数有几种方法
vue实现员工信息录入功能的方法
javascript语言支不支持多线程
javascript 从定义到执行,需要知道的事
javascript使用什么来标识
详解javascript中的作用域和作用域链
javascript怎么将整型数据转为字符串
如何处理javascript内存泄露
javascript怎么判断是否为函数
javascript数据类型的介绍
更多相关阅读请进入《javascript》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » javascript怎么求三个数的最大值