JavaScript and Examples

Introduction:

JavaScript is a scripting language that allows us to implement complex things on web page.  Displaying timely content, maps, animations, scrolling videos etc.  It also controls multimedia. With HTML and CSS JavaScript (JS) is one of the three core technologies of WWW.

HTML Defines the content of web pages.

CSS specifies the layout of web pages.

JS the behavior of web pages.

javascript

Examples:

Example 1

<!DOCTYPE html>
<html>
<body>
<h2>Click Here</h2>
<p>JavaScript can show hidden HTML elements.</p>
<p id=”demo” style=”display:none”>Hello World!</p>
<button type=”button” onclick=”document.getElementById(‘demo’).style.display=’block'”>Click Me!</button>
</body>
</html>

Example 2

JavaScript can show DATE /TIME.

Change Date and Time

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript</h2>

<button type= “button”
onclick=”document.getElementById(‘demo’).innerHTML = Date()”>
display Date and Time.</button>
<p id=demo”></p>

</body>
</html>