比较两个输入数字大小,点击按钮无反应
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>比较大小函数</title>
</head>
<body>
<input type="text" id="num1" name="num1" value="请输入第一个数" onfocus="this.value=''" onblur="if(this.value==''){this.value='请输入第一个数'}" />
<br />
+<br />
<input type="text" id="num2" name="num2" value="请输入第二个数" onfocus="this.value=''" onblur="if(this.value==''){this.value='请输入第二个数'}" />
<br />
<input type="button" id="button22" value="其中较大值是" onclick="champ(a,b)" />
<br />
</body>
<script type="text/javascript">
var a=document.getElementById(num1).value;
var b=document.getElementById(num1).value;
function champ(a,b){
if(a<b){
return b;
}
else if(a==b){
return "相等";
}
else{
return a;
}
}
document.write(champ(a,b)+"<br />");
</script>
</html>