An Introduction to jquery (+ a Primer on HTML and CSS)

Similar documents
HTML and CSS. Elliot Davies. April 10th,

CIS 467/602-01: Data Visualization

CS134 Web Site Design & Development. Quiz1

Example. Represent this as XML

Introduction to Web Development

jquery Tutorial for Beginners: Nothing But the Goods

Essential HTML & CSS for WordPress. Mark Raymond Luminys, Inc mraymond@luminys.com

Web Authoring CSS. Module Descriptor

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

Advanced Online Media Dr. Cindy Royal Texas State University - San Marcos School of Journalism and Mass Communication

Introduction to web development and JavaScript

Contents. Downloading the Data Files Centering Page Elements... 6

Module 6 Web Page Concept and Design: Getting a Web Page Up and Running

CST 150 Web Design I CSS Review - In-Class Lab

Dreamweaver CS4 Day 2 Creating a Website using Div Tags, CSS, and Templates

Web Design Basics. Cindy Royal, Ph.D. Associate Professor Texas State University

Short notes on webpage programming languages

Interactive Data Visualization for the Web Scott Murray

Introduction to web development using XHTML and CSS. Lars Larsson. Today. Course introduction and information XHTML. CSS crash course.

Web Development CSE2WD Final Examination June (a) Which organisation is primarily responsible for HTML, CSS and DOM standards?

How To Create A Web Page On A Windows (For Free) With A Notepad) On A Macintosh (For A Freebie) Or Macintosh Web Browser (For Cheap) On Your Computer Or Macbook (

How To Use Dreamweaver With Your Computer Or Your Computer (Or Your Computer) Or Your Phone Or Tablet (Or A Computer)

Links Getting Started with Widgets, Gadgets and Mobile Apps

Introduction to Web Technologies

OPENTABLE GROUP SEARCH MODULE GETTING STARTED ADD RESERVATIONS TO YOUR WEBSITE

Web Design for Programmers. Brian Hogan NAPCS Slides and content 2008 Brian P. Hogan Do not reproduce in any form without permission

ITNP43: HTML Lecture 4

We automatically generate the HTML for this as seen below. Provide the above components for the teaser.txt file.

Modern Web Development From Angle Brackets to Web Sockets

The purpose of jquery is to make it much easier to use JavaScript on your website.

Fast track to HTML & CSS 101 (Web Design)

Subject Tool Remarks What is JQuery. Slide Javascript Library

4 Understanding. Web Applications IN THIS CHAPTER. 4.1 Understand Web page development. 4.2 Understand Microsoft ASP.NET Web application development

JJY s Joomla 1.5 Template Design Tutorial:

Responsive Web Design Creative License

Level 1 - Clients and Markup

ICE: HTML, CSS, and Validation

WordPress and HTML Basics

JISIS and Web Technologies

Mobile Web Design with HTML5, CSS3, JavaScript and JQuery Mobile Training BSP-2256 Length: 5 days Price: $ 2,895.00

Cascading Style Sheets (CSS)

CSS 101. CSS CODE The code in a style sheet is made up of rules of the following types

Google Web Toolkit. Progetto di Applicazioni Software a.a. 2011/12. Massimo Mecella

<Insert Picture Here>

The Essential Guide to HTML Design

Web Building Blocks. Joseph Gilbert User Experience Web Developer University of Virginia Library

The Essential Guide to HTML Design

Advantage of Jquery: T his file is downloaded from

HTML, CSS, XML, and XSL

Intro to Web Design. ACM UIUC

Entrance exam for PBA in Web Development

Web Development I & II*

HTML5 and CSS3 Part 1: Using HTML and CSS to Create a Website Layout

Web Development 1 A4 Project Description Web Architecture

Citrix StoreFront. Customizing the Receiver for Web User Interface Citrix. All rights reserved.

Style & Layout in the web: CSS and Bootstrap

CSS. CSS - cascading style sheets CSS - permite separar num documento HTML o conteúdo do estilo. ADI css 1/28

WEB DEVELOPMENT IA & IB (893 & 894)

Dreamweaver CS5. Module 2: Website Modification

Chapter 1. Introduction to web development

Garfield Public Schools Fine & Practical Arts Curriculum Web Design

Advanced Web Development SCOPE OF WEB DEVELOPMENT INDUSTRY

Course Information Course Number: IWT 1229 Course Name: Web Development and Design Foundation

COMMONWEALTH OF PENNSYLVANIA DEPARTMENT S OF Human Services, INSURANCE, AND AGING

FETAC Certificate in Multimedia Production. IBaT College Swords. FETAC Certificate in Multimedia Production Web Authoring Dreamweaver 3

Further web design: Cascading Style Sheets Practical workbook

Responsive Web Design for Teachers. Exercise: Building a Responsive Page with the Fluid Grid Layout Feature

Last week we talked about creating your own tags: div tags and span tags. A div tag goes around other tags, e.g.,:

Web Publishing Basics 2

Taking your HTML s to the Next Level. Presented by: Joey Trogdon, Asst. Director of Financial Aid & Veterans Affairs Randolph Community College

Selectors in Action LESSON 3

Web Development Recipes

HTML CSS Basic Structure. HTML Structure [Source Code] CSS Structure [Cascading Styles] DIV or ID Tags and Classes. The BOX MODEL

Course Outline Basic Web Development

Lesson Review Answers

But have you ever wondered how to create your own website?

Web Designing with UI Designing

Create interactive web graphics out of your SAS or R datasets

LAB MANUAL CS (22): Web Technology

WRITE BETTER HTML BY WRITING BETTER CSS

Basics of HTML (some repetition) Cascading Style Sheets (some repetition) Web Design

Outline of CSS: Cascading Style Sheets

Programming in HTML5 with JavaScript and CSS3

Using Style Sheets for Consistency

Web Design I. Spring 2009 Kevin Cole Gallaudet University

How to Create an HTML Page

HTML5 & CSS3. ( What about SharePoint? ) presented

Introduction to Adobe Dreamweaver CC

Web Design Revision. AQA AS-Level Computing COMP2. 39 minutes. 39 marks. Page 1 of 17

Creating a Resume Webpage with

Microsoft Expression Web Quickstart Guide

Differences between HTML and HTML 5

HAML und SASS. (und COMPASS) markup haiku vs. syntactically awesome stylesheets. Tobias Adam, Jan Krutisch mindmatters GmbH & Co.

Overview. Understanding Web Design. Big Ideas. Goals & Audience. Theme. Theme. Big ideas. Goals & Audience Theme Navigation

Overview. How It Works

GUIDE TO CODE KILLER RESPONSIVE S

Advanced Online Media Dr. Cindy Royal Texas State University - San Marcos School of Journalism and Mass Communication

JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK

Accessibility Guidelines Bell.ca Special Needs. Cesart April 2006

{color:blue; font-size: 12px;}

Transcription:

An Introduction to jquery (+ a Primer on HTML and CSS) David Devlin - UCC ACM Student Chapter Monday 29 th November 2010

HTML and CSS Primer

What is HTML? HTML is an acronym for HyperText Markup Language. HTML is a language for annotating (marking up) a document to define its structure (e.g. titles, paragraphs, or links). The most common type of documents marked up with HTML are web pages. The process of a web browser interpreting a HTML document and displaying it is called rendering.

HTML Tags Documents are annotated by adding tags. Tags are enclosed in angle brackets, i.e. <tag>. Most tags are used in pairs, in the form <tag> content </tag>. Tags that aren t used in pairs have the form <tag />. Tags can be nested e.g. <tag1> content <tag2> content </tag2> </tag1> Nested tags must always be opened and closed in reverse order e.g. never <tag1> content <tag2> content </tag1> </tag2>

Basic Tags Web page title: <title>... </title> Paragraph: <p>... </p> Top level header: <h1>... </h1> Image: <img /> Emphasise: <em>... </em> Strongly emphasise: <strong>... </strong>

Tag Attributes Tags can contain additional information as attributes. Attributes have the form: <tag attribute-name="attribute-value">... </tag> Some attributes are required, some are optional. For example an image tag has two required attributes; src - the URL of the image file, alt - a text description the image. e.g. <img src="logo.jpg" alt="our website logo" />

HTML Document Structure The first tag in a HTML document is the <html> tag. The whole document is nested within this tag e.g. <html> rest of document </html> The <html> tag is required to contain one <head> and one <body> tag. The <head> tag contains document metadata, information about the document that is not part of the document content. The <body> tag contains the document content.

HTML Document Structure The first line of a HTML document is a doctype declaration. This is not a part of the HTML document, it is an instruction telling the web browser what version of HTML the document is written in. Doctype declarations are outside the scope of this primer.

A Complete HTML Document <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>your page title goes here.</title> </head> <body> Your content goes here. </body> </html>

HTML Examples See example-1-1.html, example-1-2.html and example-1-3.html

What is CSS? CSS is an acronym for Cascading Style Sheets. CSS is a language for describing the presentation of a marked up document, usually a HTML document.

CSS Syntax CSS has a very simple syntax: selector { property: value; property2: value2;... propertyn: valuen; } Selectors tell the browser what element you re styling. Properties tell the browser how to style the selected element.

CSS Selectors I Tags: p {... } table {... } h1 {... } Decendents: ul li {... } ol li {... } Children: ul>li {... } ol>li>ol>li {... } Multiple Selectors: ul, ol {... } p, h1 {... }

A Few Example CSS Properties color: <color> color: red; color: #ff0000; color:#f00 color: rgb(255,0,0) background-color: <color> background-color: green; background-color:#0f0 background-color: rgb(0,255,0) font-size: <size><units> font-size: 12pt; font-size: 16px; font-size: 1.5em; margin: <all><units> margin: <top-bottom><units> <right-left><units> margin: <top><units> <right><units> <bottom><units> <left><units> margin: 20px; margin: 10px 20px; margin: 50px 5px 5px 20px;

Complete CSS Rules This rule will make all ordered lists have white text on a black background: ol { color: white; background-color: black; } This rule will make all paragraphs have red text and a 20px margin: p { color: red; margin: 20px; }

Embedding or Linking CSS Embedding: CSS rules can be embedded within a <style> tag in the <head> of a HTML document: <head> <style type="text/css"> p { margin: 20px; } </style> </head> Linking an External Style Sheet: CSS rules can be placed in a separate file: <head> <link rel="stylesheet" type="text/css" href="style.css"> </head>

CSS Examples I See example-1-4.html

IDs and Classes IDs and classes are used to style specific elements or groups of elements. IDs identify a unique element, classes identify groups of elements. In HTML IDs and classes are identified using attributes. E.g: <div id="summary"> <li class="ingredients"> Elements can have more than one class. E.g: <div id="story-8" class="story unread"> <div id="story-7" class="story read">

CSS Selectors II: IDs and Classes In CSS, IDs are identified by a # symbol in the selector: #summary {... } #story-8 {... } Classes are identified by a. symbol in the selector:.story {... }.unread {... }.read {... } Classes and IDs can be joined to a tag to make a more specific selector: div#summary {... } ol.ingredients {... }

CSS Examples II See example-1-5.html

An introduction to jquery

What is JavaScript? JavaScript is a programming language. The most common use of JavaScript is to enhance webpages. Common enhancements are user interface improvement, handling dynamic events, and loading dynamic content into a page after it s been rendered.

What is jquery? jquery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jquery is designed to change the way that you write JavaScript. - jquery.com jquery makes adding dynamic behaviour to your web pages easy.

Linking or Embedding JavaScript Like CSS, JavaScript can be embedded in a HTML document or linked to a HTML document from a separate file. Both methods use the <script> tag in the document <head>. Embedding: <script type="text/javascript">... </script> Linking to external file: <script type="text/javascript" src="example.js"></script>

Including jquery Download from jquery.com, and link to your own copy: <script type="text/javascript" src="jquery.js"></script> Use the Google APIs hosted copy: <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

Using jquery Usually two steps: 1. find/select a part of the HTML document, 2. do something with it. Step 1: jquery finds parts of the document using a CSS-like selector $("p") $("ol") $("ol>li") $("ol, ul") $(".unread") $("#story-8") Step 2: jquery does something with the selected elements. $("p").hide(); $("ol").addclass("unread"); $("li").click(function(){ this.hide(); });

Using jquery Almost everything we do in jquery reads or manipulates the document, so we need to make sure that the document is loaded and ready before we do anything else. To do this, we register a ready event for the document. $(document).ready(function( ){ // do stuff when DOM is ready });

Registering Events Make all paragraphs show an alert when clicked: $(document).ready(function( ){ $("p").click(function( ){ alert("you clicked on a paragraph."); }); }); Make all paragraphs show an alert when hovered over: $(document).ready(function( ){ $("p").mouseenter(function( ){ alert("you hovered over a paragraph."); }); });

Some More Events.change().dblclick().keypress().scroll().focus()

Document Manipulation Hide paragraphs when clicked: $(document).ready(function( ){ $("p").click(function( ){ $(this).fadeout(); }); }); Change paragraph content when clicked: $(document).ready(function( ){ $("p").click(function( ){ $(this).html("updated Content"); }); });

Document Manipulation Add a CSS class when clicked: $(document).ready(function( ){ $("p").click(function( ){ $(this).addclass("red"); }); }); Make collapsible sections: $(document).ready(function( ){ $("h2").click(function( ){ $(this).next.fadetoggle(); }); });

Questions and Workshop Questions? See example-2-3.html for workshop problems