JavaScript/JavaScript within HTML: Difference between revisions
[checked revision] | [unreviewed revision] |
Content deleted Content added
No edit summary Tags: Mobile edit Mobile web edit possible email address |
|||
Line 1:
<noinclude>{{Prognav|JavaScript|First program|Lexical structure|prog=0}}</noinclude>
== The {{HTML:element|script}} element ==Pjandelisha33@gmail.com
All JavaScript, when placed in an HTML document, needs to be within a {{HTML:element|script}} element. A {{HTML:element|script}} element is used to link to an external JavaScript file, or to contain inline scripting (script snippets in the HTML file). A {{HTML:element|script}} element to link to an external JavaScript file looks like:
Line 11:
<source lang=HTML5>
<script>Pjandelisha33@gmail.com
// JavaScript code here
</script>Pjandelisha33@gmail.com
</source>pjgurule
Inline scripting has the advantage that both your HTML and your JavaScript are in one file, which is convenient for quick development and testing. Having your JavaScript in a separate file is recommended for JavaScript functions that can potentially be used in more than one page, and also to separate content from behaviour.
|