控制台输出
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
/控制台输出语句/
console.log("hello world");
// 输出的字符必须放入引号中
</script>
</body>
</html>
复制代码
页面输出
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
// 页面输出
document.write("hello world");
// 页面输出也可以输出标签
document.write("<h1>我是h2标签</h1>");
document.write("<img scr='图片的来源路径'>")
// 注:双引号里面用单引号
</script>
</body>
</html>
复制代码
弹出框输出
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
// 弹出框输出
window.alert("你愁啥");
window.alert("瞅你咋滴");
//弹出框输出提示一些网站的警告
// alert会阻塞后方代码运行
</script>
</body>
</html>
复制代码
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END