JavaScript Introduction

JavaScript is a lightweight, cross-platform, and interpreted scripting language.

 It is well-known for the development of web pages, many non-browser environments also use it. 

JavaScript can be used for Client-side developments as well as Server-side developments.

JavaScript contains a standard library of objects, like ArrayDate, and Math, and a core set of language elements like operatorscontrol structures, and statements


JavaScript HTML methods

One of many 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 ❯


JavaScript accepts both double and single quotes:

EXAMPLE ❯


JavaScript Can Change HTML Styles (CSS)

JavaScript can change Css styles such as color, font size etc. of elements using some methods such as getElementById()getElementByClassName() etc.

In the following example font style and font size of the elements have changed using getElementById() method.

EXAMPLE ❯


JavaScript Can Hide HTML Elements

Hiding HTML elements can be done by changing the display style:

 To hide an element, set the style display property to “none”.

EXAMPLE ❯


JavaScript Can Show HTML Elements

Style display property is used to hide and show the content of HTML DOM by accessing the DOM element using JavaScript/jQuery.

EXAMPLE ❯


Both hide/show HTML elements in JavaScript

Using Css style we can hide or show HTML elements in javascript. Css provides properties such as block and none to hide/show the HTML elements.

EXAMPLE ❯