html - Javascript Will Not Display in Browser -


i using javascript in external file , won't seem show up. syntax can show is: alert("welcome user");. nothing else show. below code working with.

<html>     <head>         <title>hello world</title>         <link href="style.css" type="text/css" rel="stylesheet">         <script type="text/javascript" src="script.js"></script>     </head>     <body>         <script>             var x, y, z;             x = 5;             y = 6;             z = x*y;             document.getelementbyid("z").innerhtml = z;         </script>         <h2>hello world</h2>         <p>hello world!</p>         <p class="popular">test.</p2>     </body> </html> 

the added tags see if work in html file itself. no change.

var time = new date().gethours(); if (time < 20) {   document.getelementbyid("demo").innerhtml = "have day!"; }  var x, y, z; x = 5; y = 6; z = x*y;  document.getelementbyid("demo").innerhtml = z; 

i hope can me out bothering me!

there no elements matching request elementbyid(). in addition external file executed loaded being run prior body element , html elements in being created. might prefer insert scripts prior closing body element </body>.

<html>     <head>         <title>hello world</title>         <link href="style.css" type="text/css" rel="stylesheet">     </head>     <body>         <h2>hello world</h2>         <p>hello world!</p>         <p class="popular">test.</p2>          <div id="z"></div>         <div id="demo"></div>          <script>             var x, y, z;             x = 5;             y = 6;             z = x*y;             document.getelementbyid("z").innerhtml = z;         </script>         <script type="text/javascript" src="script.js"></script>     </body> </html> 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -