HTML Javascript
In this tutorial, we will learn about Javascript and its implementation in HTML with the help of examples.
Javascript
A script is a small piece of program that can add interactivity to your website. The script could be written using JavaScript, VBScript or Typescript.
These days only JavaScript and its frameworks are being used by most of the web developers.
VBScript is not even supported by various major browsers.
<script> Element
JavaScript makes HTML pages more dynamic and interactive.
The <script> tag is used to define a client-side script (javascript).
The <script> element is used to script statements internally (inside the HTML document), or it points to an external script file through the src attribute.
Common uses for Javascript are manipulation, form validation, image, and dynamic changes of content.
Example :
<!DOCTYPE html>
<html>
<head>
<title>Script element</title>
</head>
<body>
<input type = "button" onclick = "Hello()" name = "yes" value = "click me" />
<script>
function Hello() {
alert("Hello, World!");
}
</script>
</body>
</html>
Output
<noscript> Element
The <noscript> element defines an alternate content to be displayed to users.
This element disables script in the user’s browser or has a browser that does not support scripts.
Example :
<!DOCTYPE html>
<html>
<head>
<title>Noscript element</title>
</head>
<body>
<p id = "myElement"></p>
<script>
document.getElementById("myElement").innerHTML = "Hello Javascript";
</script>
<noscript>Sorry, your browser does not support Javascript.</noscript>
<p>A Browser without the support of Javascript will show the text written inside the noscript element.</p>
</body>
</html>
Output
A Browser without the support of Javascript will show the text written inside the noscript element.
Next Tutorial
We hope that this tutorial helped you develop better understanding of the concept of Javascript in HTML.
Keep Learning : )
In the next tutorial, you'll learn about HTML fILE path
.