JavaScript stepped pit (2) script placement problem

Sure enough, there will always be learning problem, write a simple html calls for external js file, life and death does not take effect

code show as below

JavaScript:

var x = 7,y = 7,z = 9;

document.getElementById("demo").innerHTML =
    (x == y) + "<br>" + (x == z);
HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JavaScript练习</title>
    <script src="../Javascript/0113_08.js"></script>
</head>
<body>
<h2>JavaScript Booleans</h2>
<p>布尔值:true 或 false。</p>
<p id="demo"></p>
</body>
</html>

Two-line display is missing content should be displayed:

js in regard to (x == y) and (x == z) of judging the truth of
Here Insert Picture Description
thought for a long time, and finally realized that the <script>question put in the position of, <script>on <head>and <body>in effect is not the same as the

So I html file <script>has been adjusted position

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JavaScript练习</title>
</head>
<body>
<h2>JavaScript Booleans</h2>

<p>布尔值只有两个值:true 或 false。</p>
<p id="demo"></p>
<script src="../Javascript/0113_08.js"></script>
</body>
</html>

Here Insert Picture Description

Sure enough into effect, indicating that the script on the body and head of a difference

Published 20 original articles · won praise 17 · views 471

Guess you like

Origin blog.csdn.net/qwe122343/article/details/103965835