JavaScript Wonders: Unleashing the Power of Code - w9school

Navigate its vast potential, wield dynamic output, and master precise statements for web enchantment.

JavaScript Wonders: Unleashing the Power of Code  - w9school

Why Study JavaScript?

JavaScript is one of three languages that web developers have to be able to master:

1. HTML to define the web pages

2. CSS to describe Web pages' layout

3. JavaScript is used to control Web pages to behave

What Javascript can do?

JavaScript Can Change HTML Content

One of the JavaScript HTML techniques can be used is the getElementById method().

The code below "finds" an HTML element (with id="demo"), and then changes the element's contents (innerHTML) in "Hello JavaScript":

Example

document.getElementById("demo").innerHTML = "Hello JavaScript";

JavaScript accepts double and single quotes:

Example

document.getElementById('demo').innerHTML = 'Hello JavaScript';

JavaScript Can Change HTML Styles (CSS)

Modifying the appearance on an HTML element is a type of altering the appearance of an HTML attribute:

Example

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

JavaScript Can Hide HTML Elements

Hiding HTML elements is possible by altering display style: style of display. style:

Example

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

JavaScript Can Show HTML Elements

The display of hidden HTML elements may be accomplished by altering display style: style of display style:

Example

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

Did You Know?

JavaScript as well as Java Java are two completely separate languages in terms of concept and in design. JavaScript was developed by Brendan Eich in 1995 and was adopted as an ECMA standard in 1997. ECMA-262 is the formal title of the standard. ECMAScript is the name used by authorities for the language.

The Javascript Tags

JavaScript Where To

The tags.

Example:


<script>
document.getElementById("demo").innerHTML = "My First JavaScript";
</script>

Older JavaScript examples could use an attribute of type: 

JavaScript Functions and Events

An JavaScript function is a part of JavaScript code that may be executed at the time it is "called" for.

For instance, a function could be invoked whenever the occasion occurs, for instance, when a user presses on a button.

You'll find out more about the functions and the events in subsequent chapters.

JavaScript in <head> or <body>

What's Your Reaction?

like

dislike

love

funny

angry

sad

wow