java-script:hello-world
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| java-script:hello-world [2023/08/08 19:37] – odefta | java-script:hello-world [2025/01/02 18:22] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| The following script will display 'Hello World' both in a popup window and in the browser' | The following script will display 'Hello World' both in a popup window and in the browser' | ||
| < | < | ||
| + | |||
| + | ===== HTML + JS code in the same file ===== | ||
| <code javascript hello-world-js.html> | <code javascript hello-world-js.html> | ||
| Line 62: | Line 64: | ||
| <note important> | <note important> | ||
| - | If you want to select elements with the class text that are inside an element with the ID container, use **# | + | If you want to select elements with the class text that are inside an element with the ID container, use **# |
| </ | </ | ||
| Line 97: | Line 99: | ||
| </ | </ | ||
| + | ===== HTML + JS code in separated files ===== | ||
| + | |||
| + | HTML code: | ||
| + | <code html hello-world.html> | ||
| + | < | ||
| + | <html lang=" | ||
| + | < | ||
| + | <meta charset=" | ||
| + | < | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | <script src=" | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | Java Script code: | ||
| + | <code javascript hello-script.js> | ||
| + | alert(' | ||
| + | const h1 = document.querySelector(' | ||
| + | console.log(h1.textContent); | ||
| + | </ | ||
| + | |||
| + | <note tip>See also [[java-script: | ||
java-script/hello-world.1691523427.txt.gz · Last modified: (external edit)
