不知道为什么输出结果与预期不符,却没有报错,大神们帮忙看看,报错图片上传在附件
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="text" name="triangle" id="triangle1" value="0" ></input>
<input type="text" name="triangle" id="triangle2" value="0" ></input>
<input type="text" name="triangle" id="triangle3" value="0" ></input>
<input type="button" value="确认" onclick="judgement()">结果是:</input>
<span id="result">结果</span>
<script>
var judge_triangle1 =document.getElementById("triangle1").value;
var judge_triangle2 =document.getElementById("triangle2").value;
var judge_triangle3 =document.getElementById("triangle3").value;
var result=document.getElementById("result");
var compile1=judge_triangle1*1+triangle2*1;
var compile2=judge_triangle1*1-triangle2*1;
var compile3=triangle3*1;
function judgement(){
if (compile1>compile3)
{
if (compile2<compile3) {
return success() ;
}
else{
return faulse() ;
}
}
else{
return faulse() ;
}
}
function success(){
result.innerHTML="success";
}
function faulse(){
result.innerHTML="faulse";
}
</script>
</body>
</html>
相关分类