Javascript in HTML Assignment Help
Javascript in HTML
Javascript can be embedded anywhere in HTML document. The programming manner to include Javascript in the following sections
- < head>….< /head>
- < body>...< /body>
- < head>….< /head> and < body>...< /body>
- Script written as external file and include in the <head>..</head> section
Javascript in HTML Assignment Help Through Online Tutoring and Guided Sessions at MyAssignmentHelp
< head>….< /head> section
When the user perform an action the task which reside in between the <head>..</head> tags will be triggered.
< body>...< /body> section
To interpret the script and produce the output when web page loads that will be embedded in <body>…</body> section.
<head>….</head> and <body>...</body> sections
When the user perform an action the task which reside in between the <head>..</head> tags will be triggered and to interpret the script and produce the output when web page loads that will be embedded in <body>…</body> section.
The following example illustrates the above mentioned sections.
![Javascript In HTML Javascript in html img1](https://www.assignmenthelp.net/webimg/ahp/javascript-assignment-help/java-script-in-html-img1.jpg)
In the above code, the button “click on me” will be displayed while loading web page. The code is written in body section to display button . When mouse click on the button “click on me” it will show the output as follows:
Output
![Javascript In HTML Javascript in html img2](https://www.assignmenthelp.net/webimg/ahp/javascript-assignment-help/java-script-in-html-img2.jpg)
When clicking on the button, it will call the function clickme( ) to display the alert message. The function is coded in < head>…< /head> section.
The above example consists code in two section such as < head> and < body>
Embedding external file within HTML tag
Javascript can be written as external file and embedded into HTML file using the attribute src. The attribute src is associated with the tag<script></script>
External file creation:
Create a file using text editor with the extension .js.
Embedding into HTML:
{`