Horje
How to use The HTML <script> Tag

The HTML <script> tag is used to define a client-side script (JavaScript).

The <script> element either contains script statements, or it points to an external script file through the src attribute.

Common uses for JavaScript are image manipulation, form validation, and dynamic changes of content.

 

To select an HTML element, JavaScript most often uses the document.getElementById() method.


Full Example of The HTML <script> Tag

This JavaScript example writes "Hello JavaScript!" into an HTML element with id="demo":
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h2>Use JavaScript to Change Text</h2>
<p>This example writes "Hello JavaScript!" into an HTML element with id="demo":</p>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script> 

</body>
</html>

Output should be:

Full Example of The HTML <script> Tag





Related Articles
What is HTML JavaScript HTML JavaScript
How to use The HTML <script> Tag HTML JavaScript
How to create A Taste of JavaScript HTML JavaScript
How to create The HTML <noscript> Tag HTML JavaScript

Single Articles
Full Example of The HTML <script> TagHTML JavaScript

Read Full:
HTML JavaScript
Category:
Web Tutorial
Sub Category:
HTML JavaScript
Uploaded:
1 year ago
Uploaded by:
Admin
Views:
45


Reffered: https://www.w3schools.com/html/tryit.asp?filename=tryhtml_script

Share on: