HTML JAVASCRIPT

Anitha



HTML JavaScript

The HTML <script> tag is used to define a JavaScript client-side script. 
The <script> element either contains script statements or, via the src property, connects to an external script file. 

What Is An HTML JavaScript?

A script is a short piece of software that can enhance the interactivity of your website. 

A script, for example, could generate a pop-up alert box message or a dropdown menu.

JavaScript makes HTML pages more dynamic and interactive.


What Are The Different Forms Of JavaScript In HTML?

JavaScript is a dynamic type language, you do not need to define the type of the variable because it is used dynamically by the JavaScript engine. To indicate the data type, you must use var here. 

It may store any type of value, such as numbers, strings, and so on. var a=40;//holding number, for example.


The <script> Tag In HTML

  • The HTML script> tag is used to define a JavaScript client-side script.
  • The script> element either contains script statements or, via the src property, connects to an external script file.
  • JavaScript is commonly used for image manipulation, form validation, and dynamic content updates.
  • JavaScript frequently uses the document to choose an HTML element. The function getElementById().
  • This JavaScript sample inserts the text "Hello Anitha!" into an HTML element with the id="demo" attribute:


Example:


  <!DOCTYPE html>
  <html>
  <head>
  <title>JavaScript Example</title>
  </head>
  <body>
  <h1 id="demo">Hello, World!</h1>
  <script>
     // Using JavaScript
     document.getElementById("demo").innerHTML = "Hello, JavaScript!";
  </script>
  </body>
  </html>


Output:




Example:


  <!DOCTYPE html>
  <html>
  <body>
  <h2>Use of Anitha Change Text</h2>
  <p>This example writes "Hello Anitha!" into an HTML element with id="demo":</p>
  <button type="button" onclick="myFunction()">Click Me!</button>
  <p id="demo">My Demo</p>
  <script>
     function myFunction(){
     document.getElementById("demo").innerHTML = "Hello Anitha!";
  }
  </script
  </body>
  </html>


Output:








More topic in HTML

Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send