Essential Question:
- How do we use JavaScript functions to manipulate our HTML documents?
Learning Objectives:
- Identify functions to write to a HTML document
- Utilize ID's to reference HTML elements in JavaScript
- Apply knowledge of CSS styling to create dynamic JS effects.
Standards:
- NYS Next Generation Learning Standards RST.4.11-12 — Determine the meaning of symbols, key terms, and other content-specific words and phrases as they are used in scientific or technical sources.
- New York State Learning Standards CDOS 3a — Students will demonstrate mastery of the foundation skills and competencies essential for success in the workplace.
Materials:
Opening Task (25 Minutes)
- Scholars will complete opening task on Schoology covering topics learned from python foundations unit
- Randomly selected scholar will facilitate review with peers
JS Foundations Review (25 Minutes)
Review of previous day’s JS foundations covering the following topics:
<script></script>letvariable declarationsconsole.log()ifelsestatements
Break (10 Minutes)
Modifying HTML Demo (30 Minutes)
Teacher guided demonstration of using JS and HTML together:
- Writing to HTML:
document.write()- What happens when this command rus?
- Referencing existing content:
- In CSS how would I target (select) a specific element to style? ID
document.getElementById()
- Modifying content:
- In what ways would we want to modify existing content?
- Text
element.innerHTMLvselement.innerText
- Style
element.style.[propertyName]
We have to convert CSS’s kebab-casing to camelCasing for JS:- background-color -> backgroundColor
- font-family -> fontFamily
- color -> color
- Text
- In what ways would we want to modify existing content?
Buttons & Functions (30 Minutes)
Students will watch a video or read an article to learn about using buttons to trigger JavaScript functions to create the following program:
Create a HTML file called “randomness.html” and complete the following tasks:
- Create 3 Buttons, called “Simple”, “Old Style”, “Crazy Style”
- Create 3 Functions for each button
- Each button should modify the style of the website to match the button’s name