当前位置: 代码迷 >> JavaScript >> js 怎么获取方法的返回值!
  详细解决方案

js 怎么获取方法的返回值!

热度:117   发布时间:2012-04-26 14:01:31.0
js 如何获取方法的返回值!!!!
function Init(){
  alert(testA());
}

function testA(){
  //testB(); 能不能像C#那样获取
}

function testB(){
  return "hello";
}

------解决方案--------------------
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>

<title>onresize test</title>


</head>

<body onload='Init()'>

<script type="text/javascript">

    function Init() {
        alert(testA());
        
    }

    function testA() {
        var a = testB();
        return a;
       
    }

    function testB() {
        return "hello";
    }
</script>
</body>
</html>

------解决方案--------------------
<script type="text/javascript">
function Init(){
alert(testA());
}

function testA(){
return testB(); 
}

function testB(){
return "hello";

Init();
</script>
------解决方案--------------------
function Init(){
alert(testA());
}

function testA(){
return testB(); 能不能像C#那样获取
}

function testB(){
return "hello";
}

调用Init()会弹出"hello";
------解决方案--------------------
+1这样就可以获得返回值了呀。
探讨
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>

<title>onresize test</title>


</head>

<……
  相关解决方案