0% found this document useful (0 votes)
17 views

Javascript Introduction: Javascript Can Change HTML Content

JavaScript is the most popular programming language that can be used to change HTML content, attributes, and styles. It can find HTML elements by ID and modify their inner HTML, attributes like an image's src, and styles such as font size. JavaScript is also commonly used to validate user input on webpages.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Javascript Introduction: Javascript Can Change HTML Content

JavaScript is the most popular programming language that can be used to change HTML content, attributes, and styles. It can find HTML elements by ID and modify their inner HTML, attributes like an image's src, and styles such as font size. JavaScript is also commonly used to validate user input on webpages.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

JavaScript Introduction

Previous
Next Chapter

JavaScript is the most popular programming language in the world.


This page contains some examples of what JavaScript can do.

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";

JavaScript Can Change HTML Attributes


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

The Light bulb

Click the light bulb to turn on/off the light

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";

JavaScript Can Validate Data


JavaScript is often used to validate input:
Please input a number between 1 and 10

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. ECMAScript 6 (released in June 2015) is the latest
official version of JavaScript.

You might also like