<script type="text/javascript">
function min(a,b){
if(a>b){
return b;
}else{
return a;
}
alert(min);
}
min(2,5);
</script>
return之后整个函数就结束了,后面的语句都不会执行。把后面的alert删掉,alert交给外面,像这样 alert(min(a,b));
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>函数</title>
<script type="text/javascript">
function min(a,b){
if(a>b){
return b;
}else{
return a;
}
}alert(min(2,5));
</script>
</head>
<body>
</body>
</html>