如果我放在头部:
<head>
<title>我的相册</title>
<script>
let albumTip=document.getElementById("albumTip").value;
if(albumTip!=""){
alert(albumTip);
document.getElementById("albumTip").value="";
}
alert("1");
</script>
</head>
运行不生效,连显示“1”这个窗口都出不来。
如果放到</body>前面
<body>
<!--此处省略代码-->
<script>
let albumTip=document.getElementById("albumTip").value;
if(albumTip!=""){
alert(albumTip);
document.getElementById("albumTip").value="";
}
alert("1");
</script>
</body>
就ok了,执行成功!