SlideShare a Scribd company logo
1 of 24
Download to read offline
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
1 
Contents 
I/ Things force to know ........................................................................................................................ 3 
II/ Create project & structure you apps: ...................................................................................... 6 
2.1/ My first structure ...................................................................................................................... 6 
2.2/ Settings ........................................................................................................................................ 6 
2.3/ Syntax ........................................................................................................................................... 7 
2.3.1/ Rule ........................................................................................................................................ 7 
2.3.2/ Document & ready ........................................................................................................... 7 
2.3.3/ Make it works ..................................................................................................................... 9 
III/ Syntax & Events ........................................................................................................................... 12 
3.1/ Set up page for example. .................................................................................................... 12 
3.2/ Things I will do ........................................................................................................................ 12 
3.3/ Install events ............................................................................................................................ 13 
3.3.1/ Update code ...................................................................................................................... 13 
3.3.2/ OK Let’s repeat after me PLEASE. ........................................................................... 14 
3.3.3/ Test ...................................................................................................................................... 14 
3.3.4/ Update function ............................................................................................................... 15 
3.3.5/ Update code with requirement.................................................................................. 15 
3.3.6/ Run ....................................................................................................................................... 16 
3.3.7/ Update code again.......................................................................................................... 16 
3.3.8/ Run ....................................................................................................................................... 17 
3.3.9/ Analyze the problem ..................................................................................................... 18 
3.3.40/ preventDefault() ........................................................................................................... 19 
IV/ Re-structure folder & js file. ..................................................................................................... 20 
4.1/ Create js file ............................................................................................................................. 20 
4.2/ Update index.html .................................................................................................................. 20 
4.3/ Run ............................................................................................................................................... 21 
V/ Aanalysis ............................................................................................................................................ 21 
5.1/ Tab - Element .......................................................................................................................... 21
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
2 
5.2/ Tab – Source ............................................................................................................................ 22 
VI/ Simple Debug – Chrome ............................................................................................................ 23 
6.1/ Break point ................................................................................................................................ 23 
6.2/ Execute Debug ......................................................................................................................... 23 
VII/ Project file ...................................................................................................................................... 24 
VIII/ Messages from me. .................................................................................................................. 24
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
3 
Hello everybody. Long time no see. 
So today. I am going to make 1 tutorial that I think so many people care about, most of web developer. That is “jQuery”. 
For me, I was in pain with this topic for a long time. When I had a trouble, then I have searched, I have copied codes and I have parsed those example codes into my application. Even though I didn’t understand at all. No matter how hard I tried to understand this, but it was hopeless. 
After year by year, I have figure out something that is very useful and I want to share it to everyone for making a better life in web dev. 
Note: This tutorial for beginners. So you guys just jump into and enjoy it. 
Editor: Sublime 2 
I/ Things force to know 
+ jQuery site: http://jquery.com/ 
+ jQuery is written based on Javascript. It is a library (Just like library Math in C# or C++) 
+ It is different from Javascript Native: 
+ Download jquery lib:
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
4 
Look at images above. Start fighting with your mind: 
(PLEASE READ IT CAREFULLY)
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
5 
+ Question: You are going to wonder which version should we download. 
+ Answer From Completed Production (Application): It is number (1) or number (3) 
+ Answer From Developing Production (Application): It is number (2) or number (4) 
+ Question: So What difference between them ? 
+ Answer: size (1), (3) < (2), (4) 
+ Question: So What for ? 
+ Answer: For example, you have: 
+ (1 folder contains 1000 files: 4GB) (AA) 
+ [(1 folder contains 1000 files: 2GB)].zip (BB) 
+ You are going to copy it to another disk (HDD). Which one faster ?. You can try it at home. But as you can see (BB) is definitely faster than (AA). 
 Our browser is just like this. As heavier as slower (its mean: slow). 
 And if you want to understand deeper, OK search google those keywords: (Async, minified, optimize js, …)
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
6 
II/ Create project & structure you apps: 
2.1/ My first structure 
+ lib: contains library like (jquery.js, angular.js, knockout.js, backbone.js) 
+ index.html: contains html code 
 Let’s open it with Sublime 2 or another editor 
2.2/ Settings 
+ Download jquery.js uncompressed version and place it into lib folder 
+ Trust me, if you download compressed version, and do as I do, you’ve never make it work. I’ll show you later.
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
7 
2.3/ Syntax 
2.3.1/ Rule 
+ Every jQuery codes or Native Javascript codes must be place on <script></script> 
+ Everything start with $ (umcompressed-version) & jQuery (compressed- version) 
2.3.2/ Document & ready 
You have absolutely searched a lot and a lot for solution with jQuery. Right ? Don’t lie to me.
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
8 
For example, you will have this: 
+ Question: So what is it? 
+ Answer: For example: 
- Your mom asks you to bring cup of water for her. 
- You will pour water into cup. When you cup of water is full (its mean ready). 
- Bring to your mom. 
- That’s it 
 When your cup of water is ready to drink (that’s mean you cup of water is full) 
So web page is just like this:
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
9 
When all your js libraries and css are completely loaded. That means you web page is ready to do something that client want to do such as: 
- Drag image into web for uploading 
- Click choose product into cart 
- Remove product from cart. 
2.3.3/ Make it works 
Let’s update some code like this: 
Explain 1: When your site is ready (I mean that libs, images load successfully), it will pop up dialog message with content: Hello JS World 
Ok. Everything’s seen to be ready. Let’s run. Go to project folder + click index.html => Open this file with your browser. 
 Nothing is going to happen. Why ? 
Explain 2: At browser (I use Chrome) + Press F12 (to open chrome Debugger) => You will get this:
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
10 
After click likes image above. You will get this: 
 It says that you are using jQuery syntax, but you don’t include your jquery lib on your page. So the browser doesn’t understand those syntax. 
+ To solve this problem: You must load your jQuery lib before your code executes. 
Note: The order of loading javascript libs is super important. Do not forget. 
Ok Let’s update code again:
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
11 
Run again: 
 You will see that it executes like things we have expected.
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
12 
III/ Syntax & Events 
It is very hard for beginners to remember jQuery syntax. At the first time, when I first saw a syntax of jQuery. I’ve said that “Oh my god. What’s the hell is that ? It’s really hard to remember”. But don’t worry about it. I will make it become so simple to remember and understand. 
3.1/ Set up page for example. 
3.2/ Things I will do
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
13 
3.3/ Install events 
3.3.1/ Update code 
I use link <a></a> for my late purpose. Of course, you can use: button, input[type=”submit”], …etc
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
14 
3.3.2/ OK Let’s repeat after me PLEASE. 
Take a look at: 
Map above with below: 
Note: 
+ Trust me. At the beginning, when you catch event of element like button, select,… 
=> Please read orange box. I beg you. If you want to remember this syntax 
3.3.3/ Test 
Open index.html & test it. Ok click a link “Click Me !” => see what’s going to happen. 
You have just been successfully on catching even CLICK.
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
15 
3.3.4/ Update function 
+ Right now, you can catch event click. Ok let update some requirement of this example. 
+ Now I want whenever I click a link “Click Me!”. Dialog message will take value from input(text) and show it to you. 
3.3.5/ Update code with requirement. 
Work with ID 
Work with Class
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
16 
So What is val() ? 
=> jQuery has so much function. You can find out more information from jQuery home page 
=> val() : get value from input. That’s it  
3.3.6/ Run 
Open index.html on your browser > Click a link “Click Me!” => Feel the heat. 
3.3.7/ Update code again 
a/ Create file (.html) name: handsome.html
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
17 
b/ Update index.html 
3.3.8/ Run 
After you click OK. You definitely see this:
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
18 
It is right the way redirect to handsome.html 
Note: this is result that we don’t expect 
3.3.9/ Analyze the problem 
When you catch events of elements. It actually will executes 2 events.
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
19 
+ First => Our expected event. 
+ Second => Default behavior of browser => This is a thing that we don’t want to happen. 
 Question: How do we prevent from default behaviors of browser ? 
 The answer place on 3.3.40 3.3.40/ preventDefault() 
a/ Definition 
Cancel the event if it is cancelable, without stopping further propagation of the event. 
(https://developer.mozilla.org/en-US/docs/Web/API/event.preventDefault) 
b/ Update code
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
20 
 Ok now you can run & see expected results. 
IV/ Re-structure folder & js file. 
+ In the real world, JS programmer never put js code mix with html code. 
+ You have to separate js code & html code into different files. 
4.1/ Create js file 
4.2/ Update index.html
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
21 
4.3/ Run 
V/ Aanalysis 
At BROWSER => Press F12 
5.1/ Tab - Element
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
22 
5.2/ Tab – Source
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
23 
VI/ Simple Debug – Chrome 
6.1/ Break point 
6.2/ Execute Debug 
+ Click a link “Click Me!” 
+ Result right below: 
+ You can Press F10 to jump to next statement
Nguyễn Ngọc Dũng 
https://nndung179.wordpress.com/ 
24 
+ Click (1) or (2), it will finish all steps for you. 
VII/ Project file 
http://www.mediafire.com/download/v1zfcc3zz27jjnd/jQuery_Part1.rar 
VIII/ Messages from me. 
Ok you are web developers. 
So don’t be disappointed. 
Just be strong. 
I know how you feel when you are in trouble and cannot work it out. 
I hope this tutorial can bring you a passion with Javascript. 
Thank you so much.

More Related Content

Viewers also liked

3 feist ifa feist-475_older and online
3 feist ifa feist-475_older and online3 feist ifa feist-475_older and online
3 feist ifa feist-475_older and onlineifa2012_2
 
Confidentiality demonstration for mha690 discussion 2 web 2.0 tools assignment
Confidentiality demonstration for mha690 discussion 2 web 2.0 tools assignmentConfidentiality demonstration for mha690 discussion 2 web 2.0 tools assignment
Confidentiality demonstration for mha690 discussion 2 web 2.0 tools assignmentlashondadunlap
 
Bubbles of True Vacuum and Duality in M-theory
Bubbles of True Vacuum and Duality in M-theoryBubbles of True Vacuum and Duality in M-theory
Bubbles of True Vacuum and Duality in M-theorySebastian De Haro
 
Πρόσκληση εκπαιδευτών
Πρόσκληση εκπαιδευτώνΠρόσκληση εκπαιδευτών
Πρόσκληση εκπαιδευτώνiekkastorias
 
Laboratorio excel
Laboratorio excelLaboratorio excel
Laboratorio exceljosetjitt
 
1 anme ifa12integration
1 anme ifa12integration1 anme ifa12integration
1 anme ifa12integrationifa2012_2
 
2 lewin-ifa restorative care outcomes
2 lewin-ifa restorative care outcomes2 lewin-ifa restorative care outcomes
2 lewin-ifa restorative care outcomesifa2012_2
 
siskom etika-profesi
siskom etika-profesisiskom etika-profesi
siskom etika-profesihilma_alley
 
4 l.stenberg
4  l.stenberg4  l.stenberg
4 l.stenbergifa2012_2
 
Romantic age
Romantic ageRomantic age
Romantic ageAvani
 
4 minnigaleeva-ifa prague-learning_minnigaleeva1
4 minnigaleeva-ifa prague-learning_minnigaleeva14 minnigaleeva-ifa prague-learning_minnigaleeva1
4 minnigaleeva-ifa prague-learning_minnigaleeva1ifa2012_2
 
3 biggs new2 prague symposium biggs kendig clemson weds 2012
3 biggs new2 prague symposium biggs kendig clemson weds 20123 biggs new2 prague symposium biggs kendig clemson weds 2012
3 biggs new2 prague symposium biggs kendig clemson weds 2012ifa2012_2
 
สวนพลังมุ่งมั่น
สวนพลังมุ่งมั่นสวนพลังมุ่งมั่น
สวนพลังมุ่งมั่นtarn23
 
INTEGRATE 2016 - Julie Link & Greg Stroud
INTEGRATE 2016 - Julie Link & Greg Stroud INTEGRATE 2016 - Julie Link & Greg Stroud
INTEGRATE 2016 - Julie Link & Greg Stroud IMCWVU
 
2 t.k.-tk employment elderly thailand ppt
2 t.k.-tk employment elderly thailand ppt2 t.k.-tk employment elderly thailand ppt
2 t.k.-tk employment elderly thailand pptifa2012_2
 
Поликлиники Зеленограда 2014
Поликлиники Зеленограда 2014Поликлиники Зеленограда 2014
Поликлиники Зеленограда 2014Alexander Erlikh
 

Viewers also liked (20)

3 feist ifa feist-475_older and online
3 feist ifa feist-475_older and online3 feist ifa feist-475_older and online
3 feist ifa feist-475_older and online
 
Confidentiality demonstration for mha690 discussion 2 web 2.0 tools assignment
Confidentiality demonstration for mha690 discussion 2 web 2.0 tools assignmentConfidentiality demonstration for mha690 discussion 2 web 2.0 tools assignment
Confidentiality demonstration for mha690 discussion 2 web 2.0 tools assignment
 
Bubbles of True Vacuum and Duality in M-theory
Bubbles of True Vacuum and Duality in M-theoryBubbles of True Vacuum and Duality in M-theory
Bubbles of True Vacuum and Duality in M-theory
 
Πρόσκληση εκπαιδευτών
Πρόσκληση εκπαιδευτώνΠρόσκληση εκπαιδευτών
Πρόσκληση εκπαιδευτών
 
Studiemarathon
StudiemarathonStudiemarathon
Studiemarathon
 
Laboratorio excel
Laboratorio excelLaboratorio excel
Laboratorio excel
 
1 anme ifa12integration
1 anme ifa12integration1 anme ifa12integration
1 anme ifa12integration
 
2 lewin-ifa restorative care outcomes
2 lewin-ifa restorative care outcomes2 lewin-ifa restorative care outcomes
2 lewin-ifa restorative care outcomes
 
siskom etika-profesi
siskom etika-profesisiskom etika-profesi
siskom etika-profesi
 
4 l.stenberg
4  l.stenberg4  l.stenberg
4 l.stenberg
 
Romantic age
Romantic ageRomantic age
Romantic age
 
4 minnigaleeva-ifa prague-learning_minnigaleeva1
4 minnigaleeva-ifa prague-learning_minnigaleeva14 minnigaleeva-ifa prague-learning_minnigaleeva1
4 minnigaleeva-ifa prague-learning_minnigaleeva1
 
3 biggs new2 prague symposium biggs kendig clemson weds 2012
3 biggs new2 prague symposium biggs kendig clemson weds 20123 biggs new2 prague symposium biggs kendig clemson weds 2012
3 biggs new2 prague symposium biggs kendig clemson weds 2012
 
สวนพลังมุ่งมั่น
สวนพลังมุ่งมั่นสวนพลังมุ่งมั่น
สวนพลังมุ่งมั่น
 
INTEGRATE 2016 - Julie Link & Greg Stroud
INTEGRATE 2016 - Julie Link & Greg Stroud INTEGRATE 2016 - Julie Link & Greg Stroud
INTEGRATE 2016 - Julie Link & Greg Stroud
 
งานนำเสนอ1
งานนำเสนอ1งานนำเสนอ1
งานนำเสนอ1
 
2 t.k.-tk employment elderly thailand ppt
2 t.k.-tk employment elderly thailand ppt2 t.k.-tk employment elderly thailand ppt
2 t.k.-tk employment elderly thailand ppt
 
Поликлиники Зеленограда 2014
Поликлиники Зеленограда 2014Поликлиники Зеленограда 2014
Поликлиники Зеленограда 2014
 
Technical part1
Technical part1Technical part1
Technical part1
 
Hb services java ieee 2015 - 16
Hb services java ieee 2015 - 16Hb services java ieee 2015 - 16
Hb services java ieee 2015 - 16
 

Similar to jQuery Super Basic

Cross-platform Desktop Apps development using HTML, CSS, JS with Electron
Cross-platform Desktop Apps development using HTML, CSS, JS with ElectronCross-platform Desktop Apps development using HTML, CSS, JS with Electron
Cross-platform Desktop Apps development using HTML, CSS, JS with ElectronEsinniobiwa Quareeb
 
Android howto hellowidget
Android howto hellowidgetAndroid howto hellowidget
Android howto hellowidgetHiron Das
 
DevSecCon SG 2018 Fabian Presentation Slides
DevSecCon SG 2018 Fabian Presentation SlidesDevSecCon SG 2018 Fabian Presentation Slides
DevSecCon SG 2018 Fabian Presentation SlidesFab L
 
Make Mobile Apps Quickly
Make Mobile Apps QuicklyMake Mobile Apps Quickly
Make Mobile Apps QuicklyGil Irizarry
 
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014Gil Irizarry
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...Horacio Gonzalez
 
DevSecCon Singapore 2018 - Remove developers’ shameful secrets or simply rem...
DevSecCon Singapore 2018 -  Remove developers’ shameful secrets or simply rem...DevSecCon Singapore 2018 -  Remove developers’ shameful secrets or simply rem...
DevSecCon Singapore 2018 - Remove developers’ shameful secrets or simply rem...DevSecCon
 
Upgrading your site from Drupal 6 to Drupal 7
Upgrading your site from Drupal 6 to Drupal 7Upgrading your site from Drupal 6 to Drupal 7
Upgrading your site from Drupal 6 to Drupal 7Andrew Martha
 
MeCab in docker action(OpenWhisk)
MeCab in docker action(OpenWhisk)MeCab in docker action(OpenWhisk)
MeCab in docker action(OpenWhisk)KUNITO Atsunori
 
Professional web development with libraries
Professional web development with librariesProfessional web development with libraries
Professional web development with librariesChristian Heilmann
 
Future proofing design work with Web components
Future proofing design work with Web componentsFuture proofing design work with Web components
Future proofing design work with Web componentsbtopro
 

Similar to jQuery Super Basic (20)

Cpb2010
Cpb2010Cpb2010
Cpb2010
 
Cross-platform Desktop Apps development using HTML, CSS, JS with Electron
Cross-platform Desktop Apps development using HTML, CSS, JS with ElectronCross-platform Desktop Apps development using HTML, CSS, JS with Electron
Cross-platform Desktop Apps development using HTML, CSS, JS with Electron
 
Android how to hellowidget
Android how to hellowidgetAndroid how to hellowidget
Android how to hellowidget
 
Android howto hellowidget
Android howto hellowidgetAndroid howto hellowidget
Android howto hellowidget
 
Terrific Composer Workshop
Terrific Composer WorkshopTerrific Composer Workshop
Terrific Composer Workshop
 
Fewd week4 slides
Fewd week4 slidesFewd week4 slides
Fewd week4 slides
 
DevSecCon SG 2018 Fabian Presentation Slides
DevSecCon SG 2018 Fabian Presentation SlidesDevSecCon SG 2018 Fabian Presentation Slides
DevSecCon SG 2018 Fabian Presentation Slides
 
Make Mobile Apps Quickly
Make Mobile Apps QuicklyMake Mobile Apps Quickly
Make Mobile Apps Quickly
 
Wordpress as a framework
Wordpress as a frameworkWordpress as a framework
Wordpress as a framework
 
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
Make Cross-platform Mobile Apps Quickly - SIGGRAPH 2014
 
SMX_DevTools_Monaco_2.pdf
SMX_DevTools_Monaco_2.pdfSMX_DevTools_Monaco_2.pdf
SMX_DevTools_Monaco_2.pdf
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
 
Untangling4
Untangling4Untangling4
Untangling4
 
DevSecCon Singapore 2018 - Remove developers’ shameful secrets or simply rem...
DevSecCon Singapore 2018 -  Remove developers’ shameful secrets or simply rem...DevSecCon Singapore 2018 -  Remove developers’ shameful secrets or simply rem...
DevSecCon Singapore 2018 - Remove developers’ shameful secrets or simply rem...
 
Akashdeepsinghjandu13
Akashdeepsinghjandu13Akashdeepsinghjandu13
Akashdeepsinghjandu13
 
Upgrading your site from Drupal 6 to Drupal 7
Upgrading your site from Drupal 6 to Drupal 7Upgrading your site from Drupal 6 to Drupal 7
Upgrading your site from Drupal 6 to Drupal 7
 
MeCab in docker action(OpenWhisk)
MeCab in docker action(OpenWhisk)MeCab in docker action(OpenWhisk)
MeCab in docker action(OpenWhisk)
 
Professional web development with libraries
Professional web development with librariesProfessional web development with libraries
Professional web development with libraries
 
Future proofing design work with Web components
Future proofing design work with Web componentsFuture proofing design work with Web components
Future proofing design work with Web components
 
DotNetNuke
DotNetNukeDotNetNuke
DotNetNuke
 

More from David Nguyen

ACOMP_2014_submission_70
ACOMP_2014_submission_70ACOMP_2014_submission_70
ACOMP_2014_submission_70David Nguyen
 
Compressed js with NodeJS & GruntJS
Compressed js with NodeJS & GruntJSCompressed js with NodeJS & GruntJS
Compressed js with NodeJS & GruntJSDavid Nguyen
 
Javascript native OOP - 3 layers
Javascript native OOP - 3 layers Javascript native OOP - 3 layers
Javascript native OOP - 3 layers David Nguyen
 
Chứng minh số node của Heap chiều cao h
Chứng minh số node của Heap chiều cao hChứng minh số node của Heap chiều cao h
Chứng minh số node của Heap chiều cao hDavid Nguyen
 
Hướng dẫn sử dụng Mind Manager 8
Hướng dẫn sử dụng Mind Manager 8 Hướng dẫn sử dụng Mind Manager 8
Hướng dẫn sử dụng Mind Manager 8 David Nguyen
 
KTMT Lý Thuyết Tổng Quát
KTMT Lý Thuyết Tổng QuátKTMT Lý Thuyết Tổng Quát
KTMT Lý Thuyết Tổng QuátDavid Nguyen
 
KTMT Số Nguyên - Số Chấm Động
KTMT Số Nguyên - Số Chấm ĐộngKTMT Số Nguyên - Số Chấm Động
KTMT Số Nguyên - Số Chấm ĐộngDavid Nguyen
 

More from David Nguyen (12)

ACOMP_2014_submission_70
ACOMP_2014_submission_70ACOMP_2014_submission_70
ACOMP_2014_submission_70
 
Compressed js with NodeJS & GruntJS
Compressed js with NodeJS & GruntJSCompressed js with NodeJS & GruntJS
Compressed js with NodeJS & GruntJS
 
Javascript native OOP - 3 layers
Javascript native OOP - 3 layers Javascript native OOP - 3 layers
Javascript native OOP - 3 layers
 
Facebook API
Facebook APIFacebook API
Facebook API
 
Quick sort
Quick sortQuick sort
Quick sort
 
Merge sort
Merge sortMerge sort
Merge sort
 
Heap Sort
Heap SortHeap Sort
Heap Sort
 
Chứng minh số node của Heap chiều cao h
Chứng minh số node của Heap chiều cao hChứng minh số node của Heap chiều cao h
Chứng minh số node của Heap chiều cao h
 
Hướng dẫn sử dụng Mind Manager 8
Hướng dẫn sử dụng Mind Manager 8 Hướng dẫn sử dụng Mind Manager 8
Hướng dẫn sử dụng Mind Manager 8
 
KTMT Lý Thuyết Tổng Quát
KTMT Lý Thuyết Tổng QuátKTMT Lý Thuyết Tổng Quát
KTMT Lý Thuyết Tổng Quát
 
KTMT Số Nguyên - Số Chấm Động
KTMT Số Nguyên - Số Chấm ĐộngKTMT Số Nguyên - Số Chấm Động
KTMT Số Nguyên - Số Chấm Động
 
Mô Hình MVC 3.0
Mô Hình MVC 3.0Mô Hình MVC 3.0
Mô Hình MVC 3.0
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 

Recently uploaded (20)

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 

jQuery Super Basic

  • 1. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 1 Contents I/ Things force to know ........................................................................................................................ 3 II/ Create project & structure you apps: ...................................................................................... 6 2.1/ My first structure ...................................................................................................................... 6 2.2/ Settings ........................................................................................................................................ 6 2.3/ Syntax ........................................................................................................................................... 7 2.3.1/ Rule ........................................................................................................................................ 7 2.3.2/ Document & ready ........................................................................................................... 7 2.3.3/ Make it works ..................................................................................................................... 9 III/ Syntax & Events ........................................................................................................................... 12 3.1/ Set up page for example. .................................................................................................... 12 3.2/ Things I will do ........................................................................................................................ 12 3.3/ Install events ............................................................................................................................ 13 3.3.1/ Update code ...................................................................................................................... 13 3.3.2/ OK Let’s repeat after me PLEASE. ........................................................................... 14 3.3.3/ Test ...................................................................................................................................... 14 3.3.4/ Update function ............................................................................................................... 15 3.3.5/ Update code with requirement.................................................................................. 15 3.3.6/ Run ....................................................................................................................................... 16 3.3.7/ Update code again.......................................................................................................... 16 3.3.8/ Run ....................................................................................................................................... 17 3.3.9/ Analyze the problem ..................................................................................................... 18 3.3.40/ preventDefault() ........................................................................................................... 19 IV/ Re-structure folder & js file. ..................................................................................................... 20 4.1/ Create js file ............................................................................................................................. 20 4.2/ Update index.html .................................................................................................................. 20 4.3/ Run ............................................................................................................................................... 21 V/ Aanalysis ............................................................................................................................................ 21 5.1/ Tab - Element .......................................................................................................................... 21
  • 2. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 2 5.2/ Tab – Source ............................................................................................................................ 22 VI/ Simple Debug – Chrome ............................................................................................................ 23 6.1/ Break point ................................................................................................................................ 23 6.2/ Execute Debug ......................................................................................................................... 23 VII/ Project file ...................................................................................................................................... 24 VIII/ Messages from me. .................................................................................................................. 24
  • 3. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 3 Hello everybody. Long time no see. So today. I am going to make 1 tutorial that I think so many people care about, most of web developer. That is “jQuery”. For me, I was in pain with this topic for a long time. When I had a trouble, then I have searched, I have copied codes and I have parsed those example codes into my application. Even though I didn’t understand at all. No matter how hard I tried to understand this, but it was hopeless. After year by year, I have figure out something that is very useful and I want to share it to everyone for making a better life in web dev. Note: This tutorial for beginners. So you guys just jump into and enjoy it. Editor: Sublime 2 I/ Things force to know + jQuery site: http://jquery.com/ + jQuery is written based on Javascript. It is a library (Just like library Math in C# or C++) + It is different from Javascript Native: + Download jquery lib:
  • 4. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 4 Look at images above. Start fighting with your mind: (PLEASE READ IT CAREFULLY)
  • 5. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 5 + Question: You are going to wonder which version should we download. + Answer From Completed Production (Application): It is number (1) or number (3) + Answer From Developing Production (Application): It is number (2) or number (4) + Question: So What difference between them ? + Answer: size (1), (3) < (2), (4) + Question: So What for ? + Answer: For example, you have: + (1 folder contains 1000 files: 4GB) (AA) + [(1 folder contains 1000 files: 2GB)].zip (BB) + You are going to copy it to another disk (HDD). Which one faster ?. You can try it at home. But as you can see (BB) is definitely faster than (AA).  Our browser is just like this. As heavier as slower (its mean: slow).  And if you want to understand deeper, OK search google those keywords: (Async, minified, optimize js, …)
  • 6. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 6 II/ Create project & structure you apps: 2.1/ My first structure + lib: contains library like (jquery.js, angular.js, knockout.js, backbone.js) + index.html: contains html code  Let’s open it with Sublime 2 or another editor 2.2/ Settings + Download jquery.js uncompressed version and place it into lib folder + Trust me, if you download compressed version, and do as I do, you’ve never make it work. I’ll show you later.
  • 7. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 7 2.3/ Syntax 2.3.1/ Rule + Every jQuery codes or Native Javascript codes must be place on <script></script> + Everything start with $ (umcompressed-version) & jQuery (compressed- version) 2.3.2/ Document & ready You have absolutely searched a lot and a lot for solution with jQuery. Right ? Don’t lie to me.
  • 8. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 8 For example, you will have this: + Question: So what is it? + Answer: For example: - Your mom asks you to bring cup of water for her. - You will pour water into cup. When you cup of water is full (its mean ready). - Bring to your mom. - That’s it  When your cup of water is ready to drink (that’s mean you cup of water is full) So web page is just like this:
  • 9. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 9 When all your js libraries and css are completely loaded. That means you web page is ready to do something that client want to do such as: - Drag image into web for uploading - Click choose product into cart - Remove product from cart. 2.3.3/ Make it works Let’s update some code like this: Explain 1: When your site is ready (I mean that libs, images load successfully), it will pop up dialog message with content: Hello JS World Ok. Everything’s seen to be ready. Let’s run. Go to project folder + click index.html => Open this file with your browser.  Nothing is going to happen. Why ? Explain 2: At browser (I use Chrome) + Press F12 (to open chrome Debugger) => You will get this:
  • 10. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 10 After click likes image above. You will get this:  It says that you are using jQuery syntax, but you don’t include your jquery lib on your page. So the browser doesn’t understand those syntax. + To solve this problem: You must load your jQuery lib before your code executes. Note: The order of loading javascript libs is super important. Do not forget. Ok Let’s update code again:
  • 11. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 11 Run again:  You will see that it executes like things we have expected.
  • 12. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 12 III/ Syntax & Events It is very hard for beginners to remember jQuery syntax. At the first time, when I first saw a syntax of jQuery. I’ve said that “Oh my god. What’s the hell is that ? It’s really hard to remember”. But don’t worry about it. I will make it become so simple to remember and understand. 3.1/ Set up page for example. 3.2/ Things I will do
  • 13. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 13 3.3/ Install events 3.3.1/ Update code I use link <a></a> for my late purpose. Of course, you can use: button, input[type=”submit”], …etc
  • 14. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 14 3.3.2/ OK Let’s repeat after me PLEASE. Take a look at: Map above with below: Note: + Trust me. At the beginning, when you catch event of element like button, select,… => Please read orange box. I beg you. If you want to remember this syntax 3.3.3/ Test Open index.html & test it. Ok click a link “Click Me !” => see what’s going to happen. You have just been successfully on catching even CLICK.
  • 15. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 15 3.3.4/ Update function + Right now, you can catch event click. Ok let update some requirement of this example. + Now I want whenever I click a link “Click Me!”. Dialog message will take value from input(text) and show it to you. 3.3.5/ Update code with requirement. Work with ID Work with Class
  • 16. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 16 So What is val() ? => jQuery has so much function. You can find out more information from jQuery home page => val() : get value from input. That’s it  3.3.6/ Run Open index.html on your browser > Click a link “Click Me!” => Feel the heat. 3.3.7/ Update code again a/ Create file (.html) name: handsome.html
  • 17. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 17 b/ Update index.html 3.3.8/ Run After you click OK. You definitely see this:
  • 18. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 18 It is right the way redirect to handsome.html Note: this is result that we don’t expect 3.3.9/ Analyze the problem When you catch events of elements. It actually will executes 2 events.
  • 19. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 19 + First => Our expected event. + Second => Default behavior of browser => This is a thing that we don’t want to happen.  Question: How do we prevent from default behaviors of browser ?  The answer place on 3.3.40 3.3.40/ preventDefault() a/ Definition Cancel the event if it is cancelable, without stopping further propagation of the event. (https://developer.mozilla.org/en-US/docs/Web/API/event.preventDefault) b/ Update code
  • 20. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 20  Ok now you can run & see expected results. IV/ Re-structure folder & js file. + In the real world, JS programmer never put js code mix with html code. + You have to separate js code & html code into different files. 4.1/ Create js file 4.2/ Update index.html
  • 21. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 21 4.3/ Run V/ Aanalysis At BROWSER => Press F12 5.1/ Tab - Element
  • 22. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 22 5.2/ Tab – Source
  • 23. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 23 VI/ Simple Debug – Chrome 6.1/ Break point 6.2/ Execute Debug + Click a link “Click Me!” + Result right below: + You can Press F10 to jump to next statement
  • 24. Nguyễn Ngọc Dũng https://nndung179.wordpress.com/ 24 + Click (1) or (2), it will finish all steps for you. VII/ Project file http://www.mediafire.com/download/v1zfcc3zz27jjnd/jQuery_Part1.rar VIII/ Messages from me. Ok you are web developers. So don’t be disappointed. Just be strong. I know how you feel when you are in trouble and cannot work it out. I hope this tutorial can bring you a passion with Javascript. Thank you so much.