Home > Net >  Beginner Question - How do I get my JS code to show on a browser?
Beginner Question - How do I get my JS code to show on a browser?

Time:11-30

I'm using VS code as my code editor (not sure if it's relevant). My first project is on Changing Background Color. Once I'm done writing my codes, how do I get them to show on a browser?

I'm not sure how to get it to show on a browser.

CodePudding user response:

You want see your code in browser you will open live server of the code docoument -

open a HTML file and right-click on the editor and click on Open with Live Server .

or just type this url in browser

http://127.0.0.1:5500/

5500 is a default port

or just install an extensions live server it will directly open the browser.

CodePudding user response:

The best way in my opnion to execute JavaScript in your browser is to put it inside a script element inside an HTML document. I mean that in the same folder that you have the js file, create an html file and in there put the script link of the file.

 <script src="script.js" defer></script>

This need to be in the <head></head>

CodePudding user response:

hi in vscode download live server then click html file with right click and open with browser

  • Related