問題出在什么地方?。?/h1>
<!DOCTYPE? HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>函數(shù)</title>
<script type="text/javascript">
function comp(a,b)
{var a=parseInt(prompt("輸入A值"));
?var b=parseInt(prompt("輸入B值"));
? ? if(a>b){
? ? ? ? return a;
? ? }
? ? else if(a<b){
? ? ? ? return b;
? ? }
? ? else{
? ? ? ? return "兩個值相等"
? ? }
}
</script>
</head>
<body>
? ? <input type="button" onClick="comp()" value="錄入AB值">
</body>
</html>
<!DOCTYPE? HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>函數(shù)</title>
<script type="text/javascript">
function comp(a,b)
{var a=parseInt(prompt("輸入A值"));
?var b=parseInt(prompt("輸入B值"));
? ? if(a>b){
? ? ? ? return a;
? ? }
? ? else if(a<b){
? ? ? ? return b;
? ? }
? ? else{
? ? ? ? return "兩個值相等"
? ? }
}
</script>
</head>
<body>
? ? <input type="button" onClick="comp()" value="錄入AB值">
</body>
</html>
2022-01-30
沒有打印出來,
var ans=comp()
document.write(ans)
打印出來就可以看見了,結(jié)果正確的,代碼沒有問題