ITPub博客

首页 > IT职业 > > 函数能使用函数以外的变量吗?

函数能使用函数以外的变量吗?

作者:znsk07 时间:2019-04-11 15:31:59 0 删除 编辑

为什么这样可以输出
function fn(){
var txt=document.getElementById("txt").value;
var mydate =new Date();
mydate.setTime(mydate.getTime()+txt*60*60*1000);
document.write("延迟后的时间为:"+mydate+"<br/>");
}

而这样不可以呢?

var txt=document.getElementById("txt").value;
function fn(){
var mydate =new Date();
mydate.setTime(mydate.getTime()+txt*60*60*1000);
document.write("延迟后的时间为:"+mydate+"<br/>");
}

1
<br>


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27/viewspace-3133847/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-11

  • 博文量
    114
  • 访问量
    652