我有这个JS代码,我想在其中调用x var和set value。但它不工作:当函数返回x的值,结果是undefined
:JavaScript:代码问题
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<script type="text/javascript">
var myvar={
FirstL:function(){
var x='hello world';
}
}
</script>
</head>
<body>
<input type="button" value="click me" onclick="document.write(myvar.FirstL().x);" >
</body>
</html>
因为你的函数没有返回任何东西? – 2015-02-08 02:12:43
whene return我得到undefined restlt? – Ega 2015-02-08 02:13:54