<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>js输出的四种形式</title>
</head>
<body>
<!-- 第一种 alert方式-->
<script>
window.alert("hello world");
</script>
<!-- 第二种 输出到html标签-->
<script>
function modiP()
{
document.getElementById("demo").innerHTML = "更改后的界面内容";
}
</script>
<!-- 第三种 输出到html界面-->
<script>
function modiP2()
{
document.write(Date());
}
</script>
<!-- 第四种 浏览器F12查看 console-->
<script>
console.log("console test");
</script>
<p id="demo">
我是界面内容
</p>
<button onclick="modiP()">点击更改界面内容</button>
<button onclick="modiP2()">点击更改界面内容2</button>
</body>
</html>
html:输出的4种方式
最新推荐文章于 2024-09-23 14:55:17 发布