JavaScript Introduction

❮ Previous Home Next ❯

Basic Information

JavaScript is a client-side scripting language used for dynamic web pages.

It is supported by virtually all web browsers available today, such as Google Chrome, Mozilla Firefox, Apple Safari and Microsoft Edge.

JavaScript was originally developed as LiveScript by Netscape in the mid 1990s. It was later renamed to JavaScript in 1995, and became an ECMA standard in 1997.

JavaScript is a great programming language that you can use to control the user interface of your web pages.

It has a rich set of features including events, data validation and input validation, animations, alert popups and more.

JavaScript is an object-oriented language that was initially conceived to provide the building blocks for dynamic user interfaces.

It has more than 20 years of development and is still going strong even though it originally appeared out of the web industry, where JavaScript was created at Netscape in 1995.

It was recognized as a very suitable programming language for Web pages and applications, which were greatly influenced by JavaScript programs.

A few decades later, JavaScript has evolved into a full-fledged programming language with many powerful features which can be used in various scenarios.




JavaScript Can Manipulate Content

You can insert content using JavaScript HTML methods is getElementById().

The example below finds an HTML element (with id="demo"), and changes the element content (innerHTML) to "Hello JavaScript":

Example

<!DOCTYPE html>
<html>
<body>

<p id="demo">Hello World!</p>

<button onclick="myFunction()">Click Me!</button>

<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Hello JavaScript!";
}
</script>
</body>
</html>



JavaScript Hide and Show HTML Elements

You can show and hidden HTML elements:

Example

document.getElementById("demo").style.display = "block";

Example

document.getElementById("demo").style.display = "none";



JavaScript Can Change CSS Styles

You can change any styles, following example shows changing font size:

Example

document.getElementById("demo").style.fontSize = "50px";






Getting Date by Using JavaScript

You can get system date by using date() and displaying date through getElementById(), as shown in following example:

Example

function myFunction() {
  let x = document.getElementById('demo')
  x.innerHTML = Date()
}
❮ Previous Home Next ❯