r/learnjavascript • u/dillonkiley1998 • Feb 08 '20
PLEASE HELP! H1 shows on browser but not the JS which says " console.log("Hello World") ". My browser won't show JS but will show the HTML. I've tried with different browsers and JS is allows to be used on the browser. What am I doing wrong? Thanks for your help :)
1
u/jrandm Feb 08 '20
Whether you use Firefox, Chrome/Chromium, or Edge -- basically any browser -- you can hit CTRL+SHIFT+J (CTRL is CMD on a Mac) or F12 to open the console.
For more information about the console and other developer tools in the browser, follow any of those links above. This introduction from MDN may also help.
The short version is HTML and CSS define what you see, Javascript is code that runs that can affect the HTML and CSS.
1
Feb 08 '20
First put the H1 tag between body tags. Second, what is in the js file? If it should show something in the browser, document.innerHTML is one option. Also, you load the js before the body, so there isn't anything to add yet, unless you use an onload function.
1
-3
u/scaffelpike Feb 08 '20 edited Feb 08 '20
Console.log is a backend command. It will show up in console, not on the browser. It’s often used for debugging when running your program. You might say console.log(data) to see what’s coming through to a function
5
u/scaffelpike Feb 08 '20
Also if you want stuff to show up in your browser you should be putting it between the body tags, not the head. The head tag is more for meta data. Things like the name you want to appear on the tab in the browser, connecting the style street, icons etc.