SlideShare a Scribd company logo
1 of 42
Download to read offline
Intro to
 JavaScript
and JQuery
Hi!
LaunchWare.com
on the InterTubes




          dpickett
          on Twitter
Enough about me...




    to learn JavaScript!
Our Chat Today

• Where is JavaScript?
• Great uses of JavaScript
• The Basics of JavaScript
• An Intro to JQuery
Where’s JavaScript?

• Most popularly used for client side
  behaviors on web pages
• Made popular on the server side with
  NodeJS
• Start with the client side
A Note on Accessibility

• Great web developers develop with
  accessibility in mind
• Make your web pages work great without
  JavaScript using progressive
  enhancement (more on this later)
Google Maps
Twitter
Your First Program


alert(“hello BarCamp”);
alert(“hello BarCamp”);
function        string
Putting JS on your
        webpage
<script type="text/javascript">

  //your code here

  /*

       a multiline comment

  */

</script>
Putting JS on your
         webpage

<script type="text/javascript"
src="your_filename.js">
</script>
Firebug
Chrome Inspector
Node REPL
How to Install NodeJS
Let’s Refactor...
function sayHello(msg){
    alert(msg);
}


var myMessage = “Hello BarCamp!”;
sayHello(myMessage);
Let’s Refactor...
function sayHello(msg){
    alert(msg);
}
        variable assignment

var myMessage = “Hello BarCamp!”;
sayHello(myMessage);
Let’s Refactor...
function sayHello(msg){
    alert(msg);
}


var myMessage = “Hello BarCamp!”;
sayHello(myMessage);
function invocation
Let’s Refactor...
function declaration
function sayHello(msg){
    alert(msg);
}


var myMessage = “Hello BarCamp!”;
sayHello(myMessage);
Let’s Refactor...
                  argument
function sayHello(msg){
    alert(msg);
}


var myMessage = “Hello BarCamp!”;
sayHello(myMessage);
Let’s Refactor...
function sayHello(msg){
  function body
  alert(msg);
}


var myMessage = “Hello BarCamp!”;
sayHello(myMessage);
For Optimal Page
  Performance

Put your scripts at the
  end of your body
Control Logic
if(message === 'Hello'){

    alert(msg);

}

else {

    alert("Something else was set");

}
Control Logic
if(typeof window != ‘undefined’){

    alert(msg);

}

else {

    console.log(msg);

}
So Much More...

• Regular Expressions
• Loops and Iteration
• Arrays
• Objects
JQuery

• A JavaScript Framework with roots in
  Boston (John Resig)
• Removes the friction of cross-browser
  behaviors for animation, event handling,
  AJAX, and DOM manipulation
The JQuery Function

$(<selector>);

$(function(){}); // alias for $(document).ready

$(<html markup>);
Selectors
<a href="hello.html"

 class="greeting"

 style="color: blue;"

 id="greeter">Say Hello</a>



<script type="text/javascript">

 $("a");

 $("a:first");

 $("a.greeting");

 $("#greeter"); //most efficient selector

</script>
What Can I Do With a
     Selector?
$("a").css("color"); //the color of a: blue
$("a").offset().top; //position of the element
$("a").hide(); //hide the element
$("a").remove(); //remove the element
$("a").addClass("context"); //add a class
$("a").after("<p>Hello</p>")); //append
What Can I Do With a
     Selector?
$("a").css("color");

               DOM
$("a").offset().top;
$("a").hide();
       Manipulation
$("a").remove();
$("a").addClass("context");
$("a").insertAfter($("<p>Hello</p>"));
Events
<a href=‘hello.html’ id="greeter">Say Hello</a>


<script type=”text/javascript">
 $(document).ready(function(){
  $("#greeter").click(function(event){
    event.preventDefault();
    alert("Hello BarCamp!");
  });
Events
<a href=‘hello.html’ id="greeter">Say Hello</a>


<script type=”text/javascript">
 $(document).ready(function(){
  console.log('The Page Has Completely Loaded');
 });
</script>
DOM Ready Shortcut

<script type=”text/javascript">
 $(function(){
  console.log('The Page Has Completely Loaded');
 });
</script>
Events
<a href=‘hello.html’ id="greeter">Say Hello</a>


<script type=”text/javascript">
 $(document).ready(function(){
  $("#greeter").click(function(event){
    event.preventDefault();
    alert("Hello BarCamp!");
  });
Event Driven DOM
     Manipulation
<a href=‘hello.html’ id="greeter">Say Hello</a>
<script type=”text/javascript">
 $(document).ready(function(){
  $("#greeter").click(function(event){
       event.preventDefault();
       var paragraph = $("<p>").html("Hello Barcamp!");
       $(this).after(paragraph);
  });
 });
Reacting to Input
<form>
 <input id="name" name="name" type="text">
</form>


<script type="text/javascript">
 $("#name").change(function(event){
  console.log("Hello " + $("#name").val() + "!");
 });
</script>
Progressive
            Enhancement
<a href="hello.html" id="say-hello">Say Hello</a>


$(function(){
 $("#say-hello").click(function(e){
      e.preventDefault();
      //enhance the experience
 });
});
Progressive
            Enhancement
<a href="hello.html" id="say-hello">Say Hello</a>


$(function(){
 $("#say-hello").click(function(e){
      e.preventDefault();
      //enhance the experience
 });
});
So Much More..

• AJAX
• JQuery UI
• Testing
• BackboneJS
More Lengthy
     Intro to JS

Free, 4 hour session
coming this summer!
Thanks!

• Follow me on twitter @dpickett and give
  me a shout!
• Email me at dan.pickett@launchware.com
• Chat with me after the talk

More Related Content

What's hot

Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9Jack Franklin
 
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)Dotan Dimet
 
Mojolicious, real-time web framework
Mojolicious, real-time web frameworkMojolicious, real-time web framework
Mojolicious, real-time web frameworktaggg
 
Auto tools
Auto toolsAuto tools
Auto tools祺 周
 
Black-Scholes Calculator on Web
Black-Scholes Calculator on WebBlack-Scholes Calculator on Web
Black-Scholes Calculator on WebEugene Yang
 
Javascript session june 2013 (iii) jquery json
Javascript session june 2013 (iii) jquery   jsonJavascript session june 2013 (iii) jquery   json
Javascript session june 2013 (iii) jquery jsonabksharma
 
Découplez votre appli en micro-APIs
Découplez votre appli en micro-APIsDécouplez votre appli en micro-APIs
Découplez votre appli en micro-APIsNicolas Blanco
 
Mojolicious: what works and what doesn't
Mojolicious: what works and what doesn'tMojolicious: what works and what doesn't
Mojolicious: what works and what doesn'tCosimo Streppone
 
A piece of sugar in your client-side development
A piece of sugar in your client-side developmentA piece of sugar in your client-side development
A piece of sugar in your client-side developmentNicolas Blanco
 
Angular directive filter and routing
Angular directive filter and routingAngular directive filter and routing
Angular directive filter and routingjagriti srivastava
 
AngulrJS Overview
AngulrJS OverviewAngulrJS Overview
AngulrJS OverviewEyal Vardi
 
WordPress Third Party Authentication
WordPress Third Party AuthenticationWordPress Third Party Authentication
WordPress Third Party AuthenticationAaron Brazell
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile ProcessEyal Vardi
 
SINATRA + HAML + TWITTER
SINATRA + HAML + TWITTERSINATRA + HAML + TWITTER
SINATRA + HAML + TWITTERElber Ribeiro
 
WordPress Theme Design and Development Workshop - Day 3
WordPress Theme Design and Development Workshop - Day 3WordPress Theme Design and Development Workshop - Day 3
WordPress Theme Design and Development Workshop - Day 3Mizanur Rahaman Mizan
 
Railsbridge javascript
Railsbridge   javascriptRailsbridge   javascript
Railsbridge javascriptp4geoff
 

What's hot (20)

jQuery basics
jQuery basicsjQuery basics
jQuery basics
 
Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9Introduction to jQuery - Barcamp London 9
Introduction to jQuery - Barcamp London 9
 
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
 
Mojolicious, real-time web framework
Mojolicious, real-time web frameworkMojolicious, real-time web framework
Mojolicious, real-time web framework
 
Auto tools
Auto toolsAuto tools
Auto tools
 
Black-Scholes Calculator on Web
Black-Scholes Calculator on WebBlack-Scholes Calculator on Web
Black-Scholes Calculator on Web
 
Javascript session june 2013 (iii) jquery json
Javascript session june 2013 (iii) jquery   jsonJavascript session june 2013 (iii) jquery   json
Javascript session june 2013 (iii) jquery json
 
Découplez votre appli en micro-APIs
Découplez votre appli en micro-APIsDécouplez votre appli en micro-APIs
Découplez votre appli en micro-APIs
 
Introducing jQuery
Introducing jQueryIntroducing jQuery
Introducing jQuery
 
Mojolicious: what works and what doesn't
Mojolicious: what works and what doesn'tMojolicious: what works and what doesn't
Mojolicious: what works and what doesn't
 
A piece of sugar in your client-side development
A piece of sugar in your client-side developmentA piece of sugar in your client-side development
A piece of sugar in your client-side development
 
J queryui
J queryuiJ queryui
J queryui
 
Angular directive filter and routing
Angular directive filter and routingAngular directive filter and routing
Angular directive filter and routing
 
AngulrJS Overview
AngulrJS OverviewAngulrJS Overview
AngulrJS Overview
 
WordPress Third Party Authentication
WordPress Third Party AuthenticationWordPress Third Party Authentication
WordPress Third Party Authentication
 
AngularJS Compile Process
AngularJS Compile ProcessAngularJS Compile Process
AngularJS Compile Process
 
SINATRA + HAML + TWITTER
SINATRA + HAML + TWITTERSINATRA + HAML + TWITTER
SINATRA + HAML + TWITTER
 
WordPress Theme Design and Development Workshop - Day 3
WordPress Theme Design and Development Workshop - Day 3WordPress Theme Design and Development Workshop - Day 3
WordPress Theme Design and Development Workshop - Day 3
 
Railsbridge javascript
Railsbridge   javascriptRailsbridge   javascript
Railsbridge javascript
 
Jquery image slider
Jquery image slider Jquery image slider
Jquery image slider
 

Similar to Intro to JavaScript and JQuery

Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricksambiescent
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPresswpnepal
 
JavaScript on Rails 튜토리얼
JavaScript on Rails 튜토리얼JavaScript on Rails 튜토리얼
JavaScript on Rails 튜토리얼Sukjoon Kim
 
AnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkara JUG
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous JavascriptGarrett Welson
 
Primefaces Confess 2012
Primefaces Confess 2012Primefaces Confess 2012
Primefaces Confess 2012cagataycivici
 
Orlando BarCamp Why Javascript Doesn't Suck
Orlando BarCamp Why Javascript Doesn't SuckOrlando BarCamp Why Javascript Doesn't Suck
Orlando BarCamp Why Javascript Doesn't Suckerockendude
 
Client-side Rendering with AngularJS
Client-side Rendering with AngularJSClient-side Rendering with AngularJS
Client-side Rendering with AngularJSDavid Lapsley
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for JoomlaLuke Summerfield
 
ReactJs presentation
ReactJs presentationReactJs presentation
ReactJs presentationnishasowdri
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen LjuSkills Matter
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen LjuSkills Matter
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuerymanugoel2003
 
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptGuy Royse
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasminePaulo Ragonha
 

Similar to Intro to JavaScript and JQuery (20)

Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricks
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
 
Frontin like-a-backer
Frontin like-a-backerFrontin like-a-backer
Frontin like-a-backer
 
JavaScript on Rails 튜토리얼
JavaScript on Rails 튜토리얼JavaScript on Rails 튜토리얼
JavaScript on Rails 튜토리얼
 
AnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFaces
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
 
Rails is not just Ruby
Rails is not just RubyRails is not just Ruby
Rails is not just Ruby
 
Javascript
JavascriptJavascript
Javascript
 
jQuery
jQueryjQuery
jQuery
 
Primefaces Confess 2012
Primefaces Confess 2012Primefaces Confess 2012
Primefaces Confess 2012
 
Orlando BarCamp Why Javascript Doesn't Suck
Orlando BarCamp Why Javascript Doesn't SuckOrlando BarCamp Why Javascript Doesn't Suck
Orlando BarCamp Why Javascript Doesn't Suck
 
Client-side Rendering with AngularJS
Client-side Rendering with AngularJSClient-side Rendering with AngularJS
Client-side Rendering with AngularJS
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for Joomla
 
ReactJs presentation
ReactJs presentationReactJs presentation
ReactJs presentation
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScriptjQuery & 10,000 Global Functions: Working with Legacy JavaScript
jQuery & 10,000 Global Functions: Working with Legacy JavaScript
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 

More from Dan Pickett

Developing Developers Through Apprenticeship
Developing Developers Through ApprenticeshipDeveloping Developers Through Apprenticeship
Developing Developers Through ApprenticeshipDan Pickett
 
Engines Lightning Talk
Engines Lightning TalkEngines Lightning Talk
Engines Lightning TalkDan Pickett
 
5 Of Our Favorite Ruby Gems
5 Of Our Favorite Ruby Gems5 Of Our Favorite Ruby Gems
5 Of Our Favorite Ruby GemsDan Pickett
 
Refinery CMS: BostonRB CMS Showdown
Refinery CMS: BostonRB CMS ShowdownRefinery CMS: BostonRB CMS Showdown
Refinery CMS: BostonRB CMS ShowdownDan Pickett
 
VCR Lightning Talk
VCR Lightning TalkVCR Lightning Talk
VCR Lightning TalkDan Pickett
 
A Brief Introduction to JQuery Mobile
A Brief Introduction to JQuery MobileA Brief Introduction to JQuery Mobile
A Brief Introduction to JQuery MobileDan Pickett
 
So You've Got a Software Idea...Now What?
So You've Got a Software Idea...Now What?So You've Got a Software Idea...Now What?
So You've Got a Software Idea...Now What?Dan Pickett
 
It's Not Just About Code
It's Not Just About CodeIt's Not Just About Code
It's Not Just About CodeDan Pickett
 

More from Dan Pickett (8)

Developing Developers Through Apprenticeship
Developing Developers Through ApprenticeshipDeveloping Developers Through Apprenticeship
Developing Developers Through Apprenticeship
 
Engines Lightning Talk
Engines Lightning TalkEngines Lightning Talk
Engines Lightning Talk
 
5 Of Our Favorite Ruby Gems
5 Of Our Favorite Ruby Gems5 Of Our Favorite Ruby Gems
5 Of Our Favorite Ruby Gems
 
Refinery CMS: BostonRB CMS Showdown
Refinery CMS: BostonRB CMS ShowdownRefinery CMS: BostonRB CMS Showdown
Refinery CMS: BostonRB CMS Showdown
 
VCR Lightning Talk
VCR Lightning TalkVCR Lightning Talk
VCR Lightning Talk
 
A Brief Introduction to JQuery Mobile
A Brief Introduction to JQuery MobileA Brief Introduction to JQuery Mobile
A Brief Introduction to JQuery Mobile
 
So You've Got a Software Idea...Now What?
So You've Got a Software Idea...Now What?So You've Got a Software Idea...Now What?
So You've Got a Software Idea...Now What?
 
It's Not Just About Code
It's Not Just About CodeIt's Not Just About Code
It's Not Just About Code
 

Intro to JavaScript and JQuery