javascript Map

M-C

JavaScript Introduction


JavaScript is the most popular programming language in the world.

This page contains some examples of what JavaScript can do.



M-C

JavaScript Can Change HTML Content


One of many HTML methods is getElementById().

This example uses the method to "find" an HTML element (with id="demo"), and changes the element content (innerHTML) to "Hello JavaScript":

Example


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




Try yourself >>


M-C

JavaScript Can Change HTML Attributes


This example changes an HTML image, by changing the src attribute of an tag:

Example


Click the light bulb to turn on/off the light.





Try yourself >>


M-C

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 = "25px";




Try yourself >>


M-C

JavaScript Can Validate Data


JavaScript is often used to validate input:

Example

Please input a number between 1 and 10



Try yourself >>


Main Coding Home Next Chapter