HTML Elements with JavaScript and DOM Events

Slides:



Advertisements
Similar presentations
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Advertisements

CSS The basics { }. CSS Cascading Style Sheets - language used to – describe html appearance & formatting Style Sheet - file that describes – how html.
Project 8 Creating Style Sheets.
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
1 Lesson 10 Using JavaScript with Styles HTML and JavaScript BASICS, 4 th Edition Barksdale / Turner.
INTRODUCTION TO CLIENT-SIDE WEB PROGRAMMING ACM 511 ACM 262 Course Notes.
Advanced CSS - Page Layout. Advanced CSS  Compound Selectors:  Is a Dreamweaver term, not a CSS term.  Describes more advanced types of selectors such.
Styles with Cascading Style Sheets (CSS) Web Design – Section 4-1 Part or all of this lesson was adapted from the University of Washington’s “Web Design.
INTERNAL CSS Casey Ames Different types of CSS There are three different types of CSS: ◦ External CSS ◦ Internal CSS ◦ Inline CSS In this presentation.
A really fairly simple guide to: mobile browser-based application development (part 4, JQuery & DOM) Chris Greenhalgh G54UBI / Chris Greenhalgh.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
INTRODUCTION TO CSS. OBJECTIVES: D EFINE WHAT CSS IS. K NOW THE HISTORY OF CSS. K NOW THE REASON WHY CSS IS USED. CSS SYNTAX. CSS ID AND CLASS.
 cascade Style Sheets (CSS) is a mark-up language that was first proposed in 1994 by Håkon Wium Lie. CSS works in conjunction with HTML to greatly increase.
Putting Applets into Web Pages.  Two things are involved in the process of putting applets onto web pages ◦ The.class files of the applet ◦ The html.
Css. Definition Cascading style sheet (CSS)  It is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.
USING XML AS A DATA SOURCE. Data binding is a process by which information in a data source is stored as an object in computer memory. In this presentation,
Use CSS to Implement a Reusable Design Selecting a Dreamweaver CSS Starter Layout is the easiest way to create a page with a CSS layout You can access.
Web Development 101 Presented by John Valance
TOPIC II Dynamic HTML Prepared by: Nimcan Cabd Cali.
Unit 13 –JQuery Basics Instructor: Brent Presley.
INTRODUCTION JavaScript can make websites more interactive, interesting, and user-friendly.
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
Cascading Style Sheets (CSS) EXPLORING COMPUTER SCIENCE – LESSON 3-5.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Introduction to JavaScript LIS390W1A Web Technologies and Techniques 24 Oct M. Cameron Jones.
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
JavaScript JavaScript is a programming language that web browsers understand. You can use it to make your web pages interactive by: Responding to user.
LECTURE #4: JQUERY AND FORM VALIDATION Josh Kaine Josh Kaine 4/1/2016.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
Introduction to CSS: Selectors
Cascading Style Sheets (CSS)
Week-12 (Lecture-1) Cascading Style Sheets (CSS): describe how documents are presented on screens. Types of Style Sheets: External Style Sheet - Define.
Introduction to.
Web Basics: HTML/CSS/JavaScript What are they?
JavaScript/ App Lab Programming:
Objective % Select and utilize tools to design and develop websites.
Programming Web Pages with JavaScript
Week 3: Introduction to Javascript
>> JavaScript: Document Object Model
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
>> Introduction to CSS
Week 4: Introduction to Javascript
Human Computer Interaction
Styles with Cascading Style Sheets (CSS)
Concepts of HTML, CSS and Javascript
Cascading Style Sheets (CSS)
Styles with Cascading Style Sheets (CSS)
Application with Cross-Platform GUI
Retrieving information from forms
Intro to CSS CS 1150 Fall 2016.
Objective % Select and utilize tools to design and develop websites.
Introduction to JavaScript
Intro to CSS CS 1150 Spring 2017.
DHTML Javascript Internet Technology.
A second look at JavaScript
DHTML Javascript Internet Technology.
Starting to develop a website
Input CS 422: UI Design and Programming
JavaScript and the DOM MIS 2402 Jeremy Shafer Department of MIS
Training & Development
Unit 4 Test CSS Test.
Training & Development
Introduction to JavaScript
HyperText Markup Language
Web Programming and Design
Web Programming and Design
Web Programming and Design
Retrieving information from forms
Presentation transcript:

HTML Elements with JavaScript and DOM Events Madison, Hunter, and Jackson

Difference Between Using JavaScript vs CSS For the most part, the two are very similar. JavaScript is the programming language of HTML and the Web. CSS is a language that describes the style of an HTML document. CSS is relatively straight forward while JavaScript is more complicated. Overall, JS can change HTML content, attributes, styles, and elements. JavaScript allows you to create more advanced functions for your HTML page as well as have more control over them. JavaScript can also be used to create an interactive page.

Advantages of Using JavaScript vs CSS Right now, in the basic forms of programming, there isn’t a real reason to use one or the other. The real reason we are going to be using JavaScript is simply because, why not? We can use either one to do what we need to right now, but in the long run we need to be able to efficiently use both systems to accomplish higher levels of programming. JavaScript, HTML, and CSS are the 3 languages all web developers must learn.

What We are Trying to Accomplish This is why we are going to use JavaScript; to learn and expand our abilities within the system by doing things such as creating HTML elements with JavaScript. Also, we are attempting to manipulate DOM events with HTML by changing the style of same elements.

JavaScript/DOM Elements DOM Elements = Document Object Model DOM defines: the HTML elements as objects, the properties of HTML elements, the methods to access all HTML elements, and the events for all HTML elements. In order to find HTML elements in DOM you need id’s or tags such as: var myElement = document.getElementById("intro") OR var x = document.getElementsByTagName("p").

Examples of DOM Elements createCanvas() createP() createDiv() createButton() createImg() createElement(tag)

Examples of What we are Changing with JavaScript Font Color Highlight Onclick functions Position on the page Content Movement

Using HTML with JavaScript/CSS HTML is an extremely intuitive and fluid system. The way it positions its info and organizes itself is very sophisticated and well planned out. A couple of functions we are able to use are: position() tells the position on the page html() changes the content of the page

Example of How to Add an HTML With Javascript In your linked Javascript file, inside the setup function, choose which element you want to add. Ex. createCanvas(), createP(), createButton() Video - 3:10

How to Add Elements Within Other Functions You can add elements within other functions besides just the setup function. For example, you can add an element so that whenever the mouse is pressed, the element appears. To do this, add the function that you wish to include, then on the next line, add the element that you want. Video 1 - 4:50

createElement HTML elements that are commonly used have their own “create__” tags It is unrealistic to expect to remember tags for every possible HTML element Therefore, we can use the function “createElement” This function allows us to make any DOM element that isn’t already defined

How to: createElement Written as follows: Video 1 - 6:50 First set of parentheses: the tag itself Ex. h1, p, etc. Second set of parentheses: the content of the tag Video 1 - 6:50

Example JS

JavaScript ‘onClick’ Element

How to Use Variables to Store Object Information You can store information contained in a “create__” function within a variable so that you can manipulate it easier To do this, you must type the variable you wish to use in your code above the function that you want to store Ex. var canvas canvas = createCanvas(); Video 2 - 3:00 By storing information in a variable, it is much easier to change it later with position() and html()

Moving Element Locations Using the variable in the previous slide, you can now adjust an element’s location on the HTML page Ex. ______.position(0,0) Instead of a blank space, fill in the desired variable name The number in the position tag affect where on the page the element will be moved

Changing the Content of an Element The actual content of an element can be changed with a simple html() function Use the html() function like so: h1 = createElement(“h1“, “____ “) h1.html(“_____”) The content of the original element will be replaced by the content of the html() tag Video 2 - 7:50