Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Introduction to JavaScript and JQuery
Search
Dan Pickett
April 07, 2012
Programming
2
170
Introduction to JavaScript and JQuery
A quick, 30 minute crash course exploring JavaScript and JQuery
Dan Pickett
April 07, 2012
Tweet
Share
More Decks by Dan Pickett
See All by Dan Pickett
5 Favorite Gems
dpickett
2
64
The Rails Engine That Could
dpickett
2
580
Other Decks in Programming
See All in Programming
Advanced Micro Frontends: Multi Version/ Framework Scenarios @WAD 2025, Berlin
manfredsteyer
PRO
0
340
Railsアプリケーションと パフォーマンスチューニング ー 秒間5万リクエストの モバイルオーダーシステムを支える事例 ー Rubyセミナー 大阪
falcon8823
5
1.4k
NPOでのDevinの活用
codeforeveryone
0
870
AI コーディングエージェントの時代へ:JetBrains が描く開発の未来
masaruhr
1
200
なぜ「共通化」を考え、失敗を繰り返すのか
rinchoku
1
660
なんとなくわかった気になるブロックテーマ入門/contents.nagoya 2025 6.28
chiilog
1
280
Hack Claude Code with Claude Code
choplin
5
2.4k
イベントストーミング図からコードへの変換手順 / Procedure for Converting Event Storming Diagrams to Code
nrslib
2
940
What's new in AppKit on macOS 26
1024jp
0
130
Git Sync を超える!OSS で実現する CDK Pull 型デプロイ / Deploying CDK with PipeCD in Pull-style
tkikuc
3
160
新メンバーも今日から大活躍!SREが支えるスケールし続ける組織のオンボーディング
honmarkhunt
5
8.1k
Deep Dive into ~/.claude/projects
hiragram
14
8.4k
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
The Cult of Friendly URLs
andyhume
79
6.5k
The Invisible Side of Design
smashingmag
301
51k
How GitHub (no longer) Works
holman
314
140k
Navigating Team Friction
lara
187
15k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
138
34k
Code Review Best Practice
trishagee
69
19k
Building Adaptive Systems
keathley
43
2.7k
StorybookのUI Testing Handbookを読んだ
zakiyama
30
5.9k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
181
54k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
Bash Introduction
62gerente
613
210k
Transcript
Intro to JavaScript and JQuery
Hi! dpickett on Twitter LaunchWare.com on the InterTubes
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); } var myMessage = “Hello
BarCamp!”; sayHello(myMessage); variable assignment
Let’s Refactor... function sayHello(msg){ alert(msg); } var myMessage = “Hello
BarCamp!”; sayHello(myMessage); function invocation
Let’s Refactor... function sayHello(msg){ alert(msg); } var myMessage = “Hello
BarCamp!”; sayHello(myMessage); function declaration
Let’s Refactor... function sayHello(msg){ alert(msg); } var myMessage = “Hello
BarCamp!”; sayHello(myMessage); argument
Let’s Refactor... function sayHello(msg){ alert(msg); } var myMessage = “Hello
BarCamp!”; sayHello(myMessage); function body
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"); $("a").offset().top; $("a").hide();
$("a").remove(); $("a").addClass("context"); $("a").insertAfter($("<p>Hello</p>")); DOM Manipulation
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
[email protected]
• Chat with me after the talk