使用内部、外部、行内的方式, 使用js实现在页面输出hello
内部
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>第一章,js</title>
</head>
<body>
<script type="text/javascript">
document.write("<h1>hello!!!</h1>");//内部
</script>
</body>
</html>
结果
外部
<!DOCTYPE html
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>第一章,js</title>
</head>
<body>
<script type="text/javascript" src =1.js>//外部js
</script>
</body>
</html>
//用了for循环
for(var i=0; i<5;i++){
document.write("<h1>hello!!!</h1>");
}
结果
行内
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>第一章,js</title>
</head>
<body>
<script>
alert("hello!!!!!");//弹窗
</script>
</body>
</html>
结果