Tải bản đầy đủ (.pdf) (320 trang)

jquery essentials miles 2016 01 30 Lập trình Java

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.26 MB, 320 trang )

CuuDuongThanCong.com

/>

CuuDuongThanCong.com

/>

jQueryEssentials

CuuDuongThanCong.com

/>

TableofContents
jQueryEssentials
Credits
AbouttheAuthor
AbouttheReviewers
www.PacktPub.com
Supportfiles,eBooks,discountoffers,andmore
Whysubscribe?
FreeaccessforPacktaccountholders
Preface
Whatthisbookcovers
Whatyouneedforthisbook
Whothisbookisfor
Conventions
Readerfeedback
Customersupport
Downloadingtheexamplecode


Errata
Piracy
Questions
1.jQueryPartbyPart
LifebeforejQuery
WhywasjQuerycreated?
ThemajorcomponentsofjQuery
TheDOMselection
DOMmanipulation
Events
Form
CSSandanimation
Ajax
CuuDuongThanCong.com

/>

Helpers
WhyaretheretwomaintainedversionsofjQuery?
Thedifferencebetweenminifiedandun-minifiedversions
Whatisacontentdeliverynetwork?
Summary
2.jQuerySelectorsandFilters
jQueryselectors
Thechaptercode
Protocol-relativeURLs
ThejQueryobject
Creatingselectors
IDselectors
Classselectors

Tagselectors
Combiningselectors
Descendentselectors
Attributeselectors
Creatingbasicfilterselectors
Contentfilters
Usingchainingtoquicklyandneatlycontinuequeries
Summary
3.ManipulatingtheDOM
Dimensionsandpositions
Examples
Developertools
Readingthesizeofthescreenandelements
Classesandstyles
TheJSONobject
Behaviorclasses
Attributesandproperties
Keepingimagesproportional

CuuDuongThanCong.com

/>

Removingattributesandproperties
Summary
4.Events
Thereadyevent
Hookingevents
Unhookingevents
Namespacingevents

Theeventhandler
Theeventobject
event.target
event.relatedTarget
event.type
event.which
event.metaKey
event.pageXandevent.pageY
event.originalEvent
Passingdatatoanevent
Eventshorthandmethods
Creatingyourownevents
Triggeringevents
Thedeathofthe.live()and.die()methods
Lookingdeeperat.on()
Summary
5.MakingYourSiteSnazzywithjQuery
Theimportanceofanimations
Hidingandshowingelements
.fadeOut()
.fadeIn()
.fadeToggle()
Slidingelementsaround
.slideUp()

CuuDuongThanCong.com

/>

.slideDown()

.slideToggle()
Creatingcustomeffects
.animate()
.delay()
.queue(),.dequeue(),and.clearQueue()
.stop()and.finish()
jQuery.fx.intervalandjQuery.fx.off
Usingeffectscorrectly
Summary
6.BetterFormswithjQuery
Employingformmethods
.submit()
.focus()
.blur()
.focusin()and.focusout()
.change()
.select()
Tooltips
Placeholder
Enablinganddisablingelements
Validation
Filteringoutunwantedcharacters
Summary
7.TalkingtoYourServer
BeforejQuery
HowjQueryhelpsus
LoadingHTML–.load()
LoadingJSONData–.getJSON()
LoadingandexecutingJavaScript–getScript()
Readingandwritingdata:jQuery.get()and.jQuery.post()


CuuDuongThanCong.com

/>

Helpermethods
Creatingquerydata–$.param()
Creatingquerydatafromaform–.serialize()
Creatinganobjectfromformdata–.serializeArray()
Ajaxevents
WhenanAjaxrequestbegins–.ajaxStart()
WhenanAjaxrequestcompletes–.ajaxStop()
WhenanAjaxrequestsendsdata–.ajaxSend()
WhenanAjaxrequestfails–.ajaxError()
WhenanAjaxrequestsucceeds–.ajaxSuccess()
WhenanAjaxrequestfinishes–.ajaxComplete()
Summary
8.WritingCodethatYoucanReadLater
Separationofconcerns
Breakingcodeintologicalunits
Usingeventstodecouplecode
Usingunittests
Whywriteunittestsatall?
Summary
9.FasterjQuery
Writingperformancetests
MeasuringjQuery
jQueryselectors
UsingIDsoverotherselectors
Cachingyourselectors

Optimizingselectors
Righttoleft
Reducingoverlyspecificselectors
Narrowingyoursearch
OtherjQueryoptimizations
Updatingtothelatestversion

CuuDuongThanCong.com

/>

UsingthecorrectversionofjQuery
Don’tusedeprecatedmethods
UsingpreventDefault()whenappropriate
NevermodifytheDOMinaloop
jQueryisn’talwaystheanswer
Usingdocument.getElementById
UsingCSS
Summary
10.BenefitingfromtheWorkofOtherswithPlugins
Findingplugins
Installingplugins
Updatingaplugin
Uninstallingplugins
Addingaplugin
jQueryUI
jQueryUIInteractions
jQueryUIwidgets
ThejQueryUIwidgetfactory
Writingyourownplugin

Prepwork
Theplugin
Bestpractices
Preservechaining
UseanIIFE
AddonlyonefunctiontojQuery
Lettheuserthemeit
Test,test,test
Documentit
Minifyit
Summary
Index

CuuDuongThanCong.com

/>

CuuDuongThanCong.com

/>

jQueryEssentials

CuuDuongThanCong.com

/>

CuuDuongThanCong.com

/>


jQueryEssentials
Copyright©2016PacktPublishing
Allrightsreserved.Nopartofthisbookmaybereproduced,storedinaretrievalsystem,
ortransmittedinanyformorbyanymeans,withoutthepriorwrittenpermissionofthe
publisher,exceptinthecaseofbriefquotationsembeddedincriticalarticlesorreviews.
Everyefforthasbeenmadeinthepreparationofthisbooktoensuretheaccuracyofthe
informationpresented.However,theinformationcontainedinthisbookissoldwithout
warranty,eitherexpressorimplied.Neithertheauthor,norPacktPublishing,andits
dealersanddistributorswillbeheldliableforanydamagescausedorallegedtobecaused
directlyorindirectlybythisbook.
PacktPublishinghasendeavoredtoprovidetrademarkinformationaboutallofthe
companiesandproductsmentionedinthisbookbytheappropriateuseofcapitals.
However,PacktPublishingcannotguaranteetheaccuracyofthisinformation.
Firstpublished:January2016
Productionreference:1220116
PublishedbyPacktPublishingLtd.
LiveryPlace
35LiveryStreet
BirminghamB32PB,UK.
ISBN978-1-78528-635-3
www.packtpub.com

CuuDuongThanCong.com

/>

CuuDuongThanCong.com

/>


Credits
Author
TroyMiles
Reviewers
JoydipKanjilal
AnirudhPrabhu
CommissioningEditor
EdwardGordon
AcquisitionEditor
MeetaRajani
ContentDevelopmentEditor
KirtiPatil
TechnicalEditor
MohitHassija
CopyEditor
StutiSrivastava
ProjectCoordinator
NidhiJoshi
Proofreader
SafisEditing
Indexer
HemanginiBari
Graphics
KirkD’Penha
ProductionCoordinator
ShantanuN.Zagade
CoverWork
ShantanuN.Zagade


CuuDuongThanCong.com

/>

CuuDuongThanCong.com

/>

AbouttheAuthor
TroyMiles,a.k.a.theRockncoder,beganwritinggamesinassemblylanguageforearly
computers,suchastheAppleII,Vic20,C64,andtheIBMPC,over35yearsago.
Currently,hespendshisdayswritingwebappsforaSouthernCalifornia-based
automotivevaluationandinformationcompany.Duringthenightsandweekends,hecan
usuallybefoundwritingcoolappsformobileandWeborteachingotherdevelopershow
todothat.Helikestopostinterestingcodenuggetsonhisblogat
andvideosonhisYouTubechannelat
Hecanbereachedat
<>.

CuuDuongThanCong.com

/>

CuuDuongThanCong.com

/>

AbouttheReviewers
JoydipKanjilalisaMicrosoftMostValuableProfessionalinASP.NET,speaker,and
authorofseveralbooksandarticles.Hehasover18yearsofindustryexperienceinIT

withmorethan10yearsinMicrosoft.NETanditsrelatedtechnologies.Hewasselected
asMSDNFeaturedDeveloperoftheFortnight(MSDN)anumberoftimesandalsoas
CommunityCreditWinneratwww.community-credit.comseveraltimes.Hehasauthored
thefollowingbooks:
EntityFrameworkTutorialSecondEdition,PacktPublishing
ASP.NETWebAPI–BuildRESTfulWebApplicationsandServicesonthe.NET
Framework,PacktPublishing
VisualStudioSixinOne,WroxPublishers
ASP.NET4.0Programming,Mc-GrawHillPublishing
EntityFrameworkTutorial,PacktPublishing
ProSyncFramework,APRESS
SamsTeachYourselfASP.NETAjaxin24Hours,SamsPublishing
ASP.NETDataPresentationControlsEssentials,PacktPublishing
Joydiphasauthoredmorethan300articlesforsomeofthemostreputablesites,suchas
www.msdn.microsoft.com,www.code-magazine.com,www.asptoday.com,
www.devx.com,www.ddj.com,www.aspalliance.com,www.aspnetpro.com,www.sqlserver-performance.com,www.sswug.com,amongothers.Alotofthesearticleshavebeen
selectedforwww.asp.net:Microsoft’sOfficialSiteonASP.NET.
Hehasyearsofexperienceindesigningandarchitectingsolutionsforvariousdomains.
HistechnicalstrengthsincludeC,C++,VC++,Java,C#,Microsoft.NET,Ajax,WCF,
WebAPI,REST,SOA,DesignPatterns,SQLServer,OperatingSystems,andComputer
Architecture.
Heblogsatand
Hiswebsiteislocatedat
www.joydipkanjilal.com.YoucancontacthimonTwitterat
onFacebookat
andonLinkedInat
/>Writingabookhasalwaysbeenarewardingexperienceforme.Myspecialthanksgoto
theentirePacktteamforprovidingmewiththeopportunitytoreviewthisbook.Iamalso
thankfultotheentiremanagementteamatSenecaGlobalfortheircontinuedsupport.My
specialthankstomyfamilyforthecontinuedinspirationandsupport.Thankyousomuch,

all!
AnirudhPrabhuisasoftwareengineerwithover5yearsofindustryexperience.
HespecializesintechnologiessuchasHTML5,CSS3,PHP,jQuery,TwitterBootstrap,
andSASS,andhealsohasknowledgeofCoffeeScriptandAngularJS.

CuuDuongThanCong.com

/>

Inadditiontowebdevelopment,hehasbeeninvolvedinbuildingtrainingmaterialand
writingtutorialsfortwenty19(forthetechnologiesthathave
beenmentioned.
AnirudhhasauthoredBeginningCSSPreprocessorsWithSass,Compass,andLess,
Apress( />BesidesPacktPublishing,hehasbeenassociatedwithApressandManningPublications
asatechnicalreviewerforseveraltitles.

CuuDuongThanCong.com

/>

CuuDuongThanCong.com

/>

www.PacktPub.com

CuuDuongThanCong.com

/>


Supportfiles,eBooks,discountoffers,and
more
Forsupportfilesanddownloadsrelatedtoyourbook,pleasevisitwww.PacktPub.com.
DidyouknowthatPacktofferseBookversionsofeverybookpublished,withPDFand
ePubfilesavailable?YoucanupgradetotheeBookversionatwww.PacktPub.comandas
aprintbookcustomer,youareentitledtoadiscountontheeBookcopy.Getintouchwith
usat<>formoredetails.
Atwww.PacktPub.com,youcanalsoreadacollectionoffreetechnicalarticles,signup
forarangeoffreenewslettersandreceiveexclusivediscountsandoffersonPacktbooks
andeBooks.

/>DoyouneedinstantsolutionstoyourITquestions?PacktLibisPackt’sonlinedigital
booklibrary.Here,youcansearch,access,andreadPackt’sentirelibraryofbooks.

CuuDuongThanCong.com

/>

Whysubscribe?
FullysearchableacrosseverybookpublishedbyPackt
Copyandpaste,print,andbookmarkcontent
Ondemandandaccessibleviaawebbrowser

CuuDuongThanCong.com

/>

FreeaccessforPacktaccountholders
IfyouhaveanaccountwithPacktatwww.PacktPub.com,youcanusethistoaccess
PacktLibtodayandview9entirelyfreebooks.Simplyuseyourlogincredentialsfor

immediateaccess.

CuuDuongThanCong.com

/>

×