0
How do you set up a simple code with JS?
2 ответов
+ 4
Did you ask for how to run JS code?
Save it in a text file, and open it in your browser through an html file where you link the script file (or embed the JS code directly in html)...
Minimal html code to embed and run JS:
<!DOCTYPE html>
<html>
<head>
<title>my web page title<title>
<script src="myfile_path_location_usually_just_the_filename_if_same_folder_than_html"></script>
</head>
<body>
</body>
</html>
Or replace the line <script src="myfile_path_location_usually_just_the_filename_if_same_folder_than_html"></script> by:
<script>
/* here come your JS code */
</script>
<script> tag element can be placed anywhere (inside <body> or <head>), but this will have incidence on at what time is your code executed in the parsing process, and could have effects on page elements not being available at runtime (if html code come after script, you need to wait for it been parsed before be able to access it)...
+ 2
I guess as simple as this:
console.log("Hello World");