JavaScript

¡Supera tus tareas y exámenes ahora con Quizwiz!

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

JavaScript Can Hide HTML Elements

Hiding HTML elements can be done by changing the display style: Example document.getElementById("demo").style.display = "none";

Where NOT to Put the JavaScript Code

-In the <body> section of the HTML document: <body>

Document Object Model (DOM)

-All HTML tags that the browser interprets are stored in the DOM in the computer memory -Tags define elements in the DOM -JavaScript is used to manipulate these elements and the results are then instantly reflected in the browser

What is JavaScript?

A Scripting language -Typically used for client/browser scripting - -Not server side - -All modern browsers can interpret JavaScript - -JavaScript cannot make changes to the HTML document, but instead affects the Document Object Model which has been instanced by the browser, based on the HTML document

JavaScript Can Change HTML Content

One of many JavaScript HTML methods is getElementById(). The example below "finds" an HTML element (with id="demo"), and changes the element content (innerHTML) to "Hello JavaScript": Example document.getElementById("demo").innerHTML = "Hello JavaScript"; JavaScript accepts both double and single quotes: Example document.getElementById('demo').innerHTML = 'Hello JavaScript';

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 »

Document Object Model

The HTML DOM is a standard object model and programming interface for HTML. It defines: - -The HTML elements as objects -The properties of all HTML elements (values) -The methods to access all HTML elements (actions) -The events for all HTML elements - The HTML DOM is a standard for how to get, change, add, or delete HTML elements


Conjuntos de estudio relacionados

Unit 2 - Maslow's Hierarchy of Needs

View Set

Anatomy: Action Potentail and Reflexes

View Set

Ch. 1 Perspectives on Maternal and Child Health Care

View Set

Principles of Insurance and General Insurance (Ch. 1)

View Set

Chapter 1- study for test- Maternity and Peds

View Set

Introduction to Ethics - Quizzes 1-10

View Set

Human Services 001 - Chapters 7-11

View Set

Chapter 7 Notes- Light Zones/Color in the Ocean

View Set