16
javascript & jquery 22-3375 Web Design I // Columbia College Chicago

Intro to Javascript and jQuery

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Intro to Javascript and jQuery

javascript & jquery22-3375 Web Design I // Columbia College Chicago

Page 2: Intro to Javascript and jQuery

Student Presentations

Present portfolio mockups

Walk us through the !ow (homepage, detail, about)

What types of work will you be showing?

Any special interactions that you need to work out?

Will you be able to code this by the end of the course?

Page 3: Intro to Javascript and jQuery

What is a javascript?JavaScript (sometimes abbreviated JS) is a scripting language commonly implemented as part of a web browser in order to create enhanced user interfaces and dynamic websites.

Javascript is a client-side programming language, which means that it resides on the client’s machine and not on the server (in your browser).

Page 4: Intro to Javascript and jQuery

Javascript Syntax

Page 5: Intro to Javascript and jQuery

Every script is made up of a series of statements.

<script>!rst statement;second statement;</script>

Page 6: Intro to Javascript and jQuery

A JavaScript function is a "recipe" of instructions (i.e., statements or commands) whose purpose is to accomplish a well-de"ned task.

<script>

function square (number){var result = number * number;return result;}

</script>

Page 7: Intro to Javascript and jQuery

Variables in JavaScript are similar to the variables you may have studied in high school algebra. You can think of variables as "holding places" where values are stored and retrieved.

<script>

greeting = "Hello";greeting = greeting + ", my friend.";

</script>

Page 8: Intro to Javascript and jQuery

Where does javascript go?

Javascript is usually typed in the <head> element, in a linked .js !le, or both.

Page 9: Intro to Javascript and jQuery

Where does javascript go?

Javascript is usually typed in the <head> element, in a linked .js !le, or both.

Page 10: Intro to Javascript and jQuery

Try It

<script> function displayDate( { document.getElementById("date").innerHTML=Date(); }</script>

Page 11: Intro to Javascript and jQuery

Getting Started with jquery

Page 12: Intro to Javascript and jQuery

What is a jquery?jQuery is a multi-browser JavaScript library designed to simplify the client-side scripting of HTML.

“Library” in this contexts means a group of javascript functions (which you might see referred to as methods) that you can access and run on your page with very little coding.

jQuery is javascript, but it uses it’s own “selector engine” that is very designer friendly. A “selector engine” is just the way that you reference elements in your html in order to make the do something. jQuery uses CSS selectors, which you already know how to use!

Page 13: Intro to Javascript and jQuery

Where does jquery go?

The jquery library is linked from the <head> document. You can download the jquery !le from jquery.com, or link to the Google version. It should go below your CSS, but above any scripts or plugins.

Page 14: Intro to Javascript and jQuery

Where does jquery go?

Page 15: Intro to Javascript and jQuery

Where does jquery go?

Page 16: Intro to Javascript and jQuery

Try It

<script> $(document).ready(function(){ $(".btn-slide").click(function(){ $("#panel").slideToggle("slow"); $(this).toggleClass("active"); return false }); }); </script>