0% found this document useful (0 votes)
2 views7 pages

JavaScript Basics: HTML Manipulation Guide

This document discusses different ways JavaScript can manipulate HTML content and attributes, change styles, hide and show elements, and output text. It explains that JavaScript code can be placed in <script> tags in the <head> or <body> section, or externally linked. Common statements like semicolons, code blocks, and variable declarations are also covered. Finally, it reviews several methods for displaying output, including innerHTML, document.write(), window.alert(), and print.

Uploaded by

TANTULAR RESCUE
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

JavaScript Basics: HTML Manipulation Guide

This document discusses different ways JavaScript can manipulate HTML content and attributes, change styles, hide and show elements, and output text. It explains that JavaScript code can be placed in <script> tags in the <head> or <body> section, or externally linked. Common statements like semicolons, code blocks, and variable declarations are also covered. Finally, it reviews several methods for displaying output, including innerHTML, document.write(), window.alert(), and print.

Uploaded by

TANTULAR RESCUE
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

JS Introduction
JavaScript Can Change HTML Content
JavaScript accepts both double and single quotes:
 [Link]("demo").innerHTML = "Hello JavaScript";
 [Link]('demo').innerHTML = 'Hello JavaScript';

JavaScript Can Change HTML Attribute Values

JavaScript Can Change HTML Styles (CSS)

JavaScript Can Hide HTML Elements

JavaScript Can Show HTML Elements


2. JavaScript Where To

The <script> Tag

JavaScript Functions and Events


JavaScript in <head> or <body>
JavaScript in <head>

JavaScript in <body>

External JavaScript
External References
uses a full URL to link to a script:

uses a script located in a specified folder on the current web site:

inks to a script located in the same folder as the current page:


3. JavaScript Output
Using innerHTML

Using [Link]()

Using [Link]() after an HTML document is loaded, will delete all existing HTML:

Using [Link]() / alert()

JavaScript Print
4. JavaScript Statements

Semicolons ;

When separated by semicolons, multiple statements on one line are allowed:

JavaScript White Space


JavaScript Line Length and Line Breaks

JavaScript Code Blocks


JavaScript Syntax

JavaScript Literals

JavaScript Variables

You might also like