What JavaScript can do?

It can do following operations:

  • JavaScript can change HTML Content.
  • JavaScript can change HTML Attribute Values.
  • JavaScript can change HTML Styles (CSS).
  • JavaScript can Hide HTML Elements.
  • JavaScript can Show HTML Elements.

Example:

The following example shows an alert dialog box of JavaScript that is contained inside the head tag. Here, we are creating a function msg(). To create this function in JavaScript, We need to write function with function_name as given.

To call function, we need to work on event. Here we are using the onclick event to call msg() function.

<html>   

<head>   

<script type="text/javascript">   

function msg(){   

 alert("Hello Javatpoint");   

}   

</script>   

</head>   

<body>   

<p>Welcome to JavaScript</p>   

<form>   

<input type="button" value="click" >

Difference Between Java and JavaScript

In this article, we have explained the difference between Java and JavaScript, because most of the time beginners get confused… Read More

4 years ago