You are on page 1of 1

Dark code

 HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP BOOTSTRAP HOW TO W3.CSS C C++ C# REACT R JQUERY DJANGO TYPESCRIPT NODEJS    
 Tutorials  References  Exercises  Videos Upgrade Get Certified Free Website

JS Tutorial
JS HOME
JS Introduction

JavaScript Introduction
JS Where To
JS Output
JS Statements
JS Syntax ❮ Previous Next ❯
JS Comments
JS Variables
JS Let
JS Const This page contains some examples of what JavaScript can do.
JS Operators
JS Arithmetic
JS Assignment
JS Data Types
JS Functions JavaScript Can Change HTML Content
JS Objects
One of many JavaScript HTML methods is getElementById() . COLOR PICKER
JS Events
JS Strings The example below "finds" an HTML element (with id="demo"), and changes the element content (innerHTML) to "Hello JavaScript":
JS String Methods
JS String Search
JS String Templates Example
JS Numbers 
JS BigInt document.getElementById("demo").innerHTML = "Hello JavaScript";
JS Number Methods
JS Number Properties Try it Yourself » Get certified
JS Arrays by completing
JS Array Methods
a JavaScript
JS Array Sort
course today!
JS Array Iteration
JavaScript accepts both double and single quotes:
JS Array Const
school
JS Dates w3 s

JS Date Formats
JS Date Get Methods
JS Date Set Methods
Example

2
CE

02
TI 2

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

Try it Yourself »
Get started

JavaScript Can Change HTML Attribute Values


In this example JavaScript changes the value of the src (source) attribute of an <img> tag:

The Light Bulb

Turn on the light Turn off the light

Try it Yourself »

JavaScript Can Change HTML Styles (CSS)


Changing the style of an HTML element, is a variant of changing an HTML attribute:

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

Try it Yourself »

JavaScript Can Hide HTML Elements


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

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

Try it Yourself »

JavaScript Can Show HTML Elements


Showing hidden HTML elements can also be done by changing the display style:

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

Try it Yourself »

Did You Know?


JavaScript and Java are completely different languages, both in concept and design.

JavaScript was invented by Brendan Eich in 1995, and became an ECMA standard in 1997.

ECMA-262 is the official name of the standard. ECMAScript is the official name of the language.

JavaScript Versions »

❮ Previous Next ❯

Report Error Spaces Upgrade Newsletter Get Certified

Top Tutorials Top References Top Examples Get Certified


HTML Tutorial HTML Reference HTML Examples HTML Certificate
CSS Tutorial CSS Reference CSS Examples CSS Certificate
JavaScript Tutorial JavaScript Reference JavaScript Examples JavaScript Certificate
How To Tutorial SQL Reference How To Examples Front End Certificate
SQL Tutorial Python Reference SQL Examples SQL Certificate
Python Tutorial W3.CSS Reference Python Examples Python Certificate
W3.CSS Tutorial Bootstrap Reference W3.CSS Examples PHP Certificate
Bootstrap Tutorial PHP Reference Bootstrap Examples jQuery Certificate
PHP Tutorial HTML Colors PHP Examples Java Certificate
Java Tutorial Java Reference Java Examples C++ Certificate
C++ Tutorial Angular Reference XML Examples C# Certificate
jQuery Tutorial jQuery Reference jQuery Examples XML Certificate

FORUM | ABOUT

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using
W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2022 by Refsnes Data. All Rights Reserved.


W3Schools is Powered by W3.CSS.

You might also like