JavaScript Introduction


JavaScript Can Change HTML Content

One of the techniques in JavaScript for working with HTML is called getElementById().

In the code below, we locate an HTML element with the identifier "demo" and modify the content inside it (innerHTML) to display "Hello JavaScript":

JavaScript allows you to use either double quotation marks or single quotation marks.:


JavaScript Can Change HTML Attribute Values

In this illustration, JavaScript modifies the content of the "src" (source) attribute within an "<img>" tag using the following code tag:


JavaScript Can Change HTML Styles (CSS)

Modifying how an HTML element looks is similar to altering an HTML property:


JavaScript Can Hide HTML Elements

You can hide things on a webpage by adjusting the "display" style in HTML using the display attribute:


JavaScript Can Show HTML Elements

You can reveal hidden parts of a webpage by adjusting the "display" style attribute in HTML.