<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script>
window.alert("弹窗");
//document.getElementById("gaibian").innerHTML = "段落已修改。";
document.write(Date());//弹出时间
console.log("控制台输出");
function myFunction()
{
document.getElementById("demo").innerHTML ="我的第一个 JavaScript 函数";
}
function myFunctiontC() {
document.write(Date());
}
</script>
</head>
<body>
<h1>我的 Web 页面</h1>
<p id="demo">一个段落</p>
<!--在标签中填写onclick事件调用 函数时,不是onclick=函数名,二十onclick=函数名()-->
<button type="button" onclick="myFunction()">尝试一下</button>
<!--js弹窗
windows.alert();警告框
document.write()方法将内容写到HTMl文档
innerHtml写入html元素中
------使用 document.write() 仅仅向文档输出写内容。
如果在文档已完成加载后执行 document.write,整个 HTML 页面将被覆盖。-----
console.log 写入控制台,控制台输出
-->
<p id="gaibian">原本内容</p>
<button type="button" onclick="myFunctiontC()">弹出时间</button>
<script>
//script写在前面代码会先加载,所以文本修改,要在文本标签之后写script
document.getElementById("gaibian").innerHTML = "段落已修改。";
</script>
</body>
</html>