global variable in java script pass value from inside to outside the function

1252 views javascript
4

how pass the value from inside to outside the function so that i can use it.. ...

          <script>
              var globe;
              var echo=globe;
            function check(){
           this.globe=90;  
             alert(echo); 
            }

           </script>
</head>
    <body>

          <a href='javascript:;' onclick='check();' >open</a>           
       </body>
      </html>

answered question

1 Answer

6

You have to do the assignment in side the function and after the assignment into the globe:

var globe;
var echo;
function check(){
  globe=90;
  echo=globe;
  alert(echo); 
}
<a href='javascript:;' onclick='check();' >open</a>

posted this

Have an answer?

JD

Please login first before posting an answer.