elibraryportal Logo

JS Example

There are three way to use of Java Script Example . that is

  1. Use in body tag of html
  2. Use in head tag of html
  3. Use in external javaScript file .js

Syntax:

1) Use in body tag Example

Display a alert dialog box.

Example:

Test it Now

2) Use in head tag Example

Create a function in JavaScript you need to onclick event to call msg() function..

Example:

Test it Now

3) Use in external javaScript file (.js) Example

When we can write JavaScript code in other file having an extension .js and link the file inside the <head> tag of the HTML file.

Example

index.html

p.js

Note: JS file is link to index.html file

Test it Now
Next TopicJS Comments