jQuery Tutorial
Select, animate and update web pages with the classic JavaScript library.
Getting started6 lessons
- 1jQuery IntroductionjQuery is a small JavaScript library that makes selecting elements, handling events, anima.
- 2jQuery Get StartedAdd jQuery with a script tag from a CDN or install it with npm.
- 3jQuery SyntaxThe basic form is $(selector).action().
- 4The Document Ready EventWrap code in a ready handler so it runs after the DOM has loaded.
- 5jQuery versus Plain JavaScriptModern JavaScript has querySelector, classList and fetch, so many jQuery tasks are now one.
- 6Method ChainingMost jQuery methods return the jQuery object, so you can chain several actions in one stat.
Selectors6 lessons
- 7Basic SelectorsjQuery uses CSS selectors: tag names, #id and .class.
- 8Combining SelectorsUse commas to select several groups, spaces for descendants and > for direct children.
- 9Filter SelectorsjQuery adds filters such as :first, :even, :odd, :visible and :hidden.
- 10Attribute and Form SelectorsSelect by attributes with brackets and by form type with :text, :checked and :selected.
- 11The this KeywordInside an event handler, this is the DOM element that triggered it.
- 12Selector PerformanceID selectors are fastest, class selectors next.
Events6 lessons
- 13Click and Mouse Eventsclick, dblclick, mouseenter, mouseleave and hover react to the mouse.
- 14Keyboard and Form Eventskeydown, keyup and keypress track typing.
- 15The on() Methodon attaches one or more handlers, and off removes them.
- 16Event DelegationAttach one handler to a parent and give a selector so it also works for elements added lat.
- 17The Event ObjectThe handler receives an event with details such as target, pageX, key and which.
- 18Triggering and Custom Eventstrigger fires an event from code.
Effects6 lessons
- 19Hide, Show and Togglehide, show and toggle change visibility, optionally with a speed such as slow, fast or mil.
- 20FadingfadeIn, fadeOut, fadeToggle and fadeTo change opacity over time.
- 21SlidingslideDown, slideUp and slideToggle animate height.
- 22Custom Animationsanimate changes numeric CSS properties over time.
- 23Stop, Delay and Queuestop ends the running animation, delay pauses the queue and finish jumps to the end.
- 24Prefer CSS for Simple EffectsCSS transitions and animations run on the GPU and are smoother than jQuery animations.
DOM manipulation8 lessons
- 25Get and Set Contenttext, html and val read or write content.
- 26Attributes and Propertiesattr reads and writes attributes.
- 27Add Elementsappend and prepend add inside an element, after and before add outside.
- 28Remove Elementsremove deletes elements and their data, empty clears the children, detach keeps data for r.
- 29Working with ClassesaddClass, removeClass, toggleClass and hasClass control classes.
- 30The css() Methodcss reads and writes style properties.
- 31Dimensions and Positionwidth and height get content size, innerWidth adds padding, outerWidth adds border, offset.
- 32Clone, Wrap and Replaceclone copies elements, wrap puts a wrapper around them and replaceWith swaps them for some.
Traversing14 lessons
- 33Parents and Childrenparent, parents, children and closest move up and down the tree.
- 34Siblingssiblings, next, prev, nextAll and prevUntil move sideways between elements with the same p.
- 35Filteringfirst, last, eq, filter, not and has narrow a selection.
- 36Looping with eacheach runs a function for every element.
- 37find versus childrenfind searches all descendants and children only direct ones.
- 38Parent Methodsparent, parents and closest walk up the tree.
- 39Children and Findchildren looks one level down and find goes deep.
- 40Siblingssiblings, next, prev, nextAll and prevAll move sideways.
- 41filter, not, first, last, eqNarrow a set of matches.
- 42each Loopeach runs a function on every match.
- 43map, is and hasTransform sets and test conditions.
- 44ChainingMost methods return the jQuery object so calls can chain.
- 45length and indexlength counts matches and index finds position.
- 46add, end and andSelfCombine sets and step back in a chain.
AJAX6 lessons
- 47AJAX IntroductionAJAX loads data from the server without reloading the page.
- 48get and post$.get reads data and $.post sends it.
- 49The load() Methodload fetches HTML from a URL and puts it into the selected element.
- 50JSON DatagetJSON fetches and parses JSON.
- 51Promises and DeferredsAJAX methods return a jqXHR with done, fail and always.
- 52Submitting Forms with AJAXserialize turns form fields into a query string.
Advanced jQueryPremium11 lessons
- 53Writing a PluginA plugin adds methods to $.fn so every selection can use them.
- 54extend and Options$.extend merges objects, which plugins use to combine defaults and user options.
- 55The data() Storedata stores values on elements without touching the DOM attributes, and removeData clears .
- 56Deferred Objects$.Deferred lets you create your own async tasks.
- 57Event NamespacesAdd a namespace to event names such as click.menu so you can remove just your handlers.
- 58jQuery UIjQuery UI adds widgets such as datepicker, dialog, sortable and autocomplete plus interact.
- 59Custom Selectors and FiltersExtend jQuery with your own pseudo selectors through $.expr.
- 60Global AJAX Setup and ErrorsajaxSetup sets defaults and global events such as ajaxStart show spinners.
- 61CORS, JSONP and SecurityBrowsers block cross origin requests unless the server allows them with CORS.
- 62Chaining Requeststhen lets you run requests one after another, and when runs them in parallel.
- 63Upgrading and jQuery MigratejQuery 3 removed many old methods such as bind and live.
jQuery in practicePremium10 lessons
- 64Build an AccordionShow one panel at a time.
- 65Build TabsUse href or data attributes to link a tab with its panel.
- 66Form ValidationCheck fields on submit, show messages beside them and block sending when invalid.
- 67Live Search FilterFilter a list as the user types by toggling items that match the text.
- 68Build a ModalShow an overlay and dialog, close on a button, on the overlay click and on the Escape key.
- 69Infinite Scroll and Lazy LoadingListen to scroll, check how near the bottom you are and load the next page.
- 70Debugging jQueryCheck that the selection found elements with length, log with console.log and use browser .
- 71Performance TipsCache selectors, delegate events, batch DOM writes, avoid layout thrashing and use CSS for.
- 72Moving from jQuery to Vanilla JSReplace methods with native ones step by step: querySelector, classList, addEventListener,.
- 73jQuery Best PracticesLoad jQuery at the end of body, cache selections, use delegation, avoid inline handlers, p.
jQuery foundations12 lessons
- 74Document ReadyRun code after the DOM is ready.
- 75Basic SelectorsUse CSS selectors inside $().
- 76Selector FiltersFilters like :first, :even, :not and :contains refine matches.
- 77text, html and valtext reads text, html reads markup and val reads form values.
- 78attr and propattr reads attributes and prop reads live properties.
- 79css Methodcss reads and sets styles.
- 80ClassesaddClass, removeClass, toggleClass and hasClass manage classes.
- 81Width and Heightwidth, height, innerWidth and outerHeight measure elements.
- 82Adding Contentappend, prepend, before and after insert content.
- 83Removing Contentremove deletes elements and empty clears children.
- 84Cloningclone copies elements, optionally with events.
- 85Wrapping Elementswrap, wrapAll and unwrap change structure.
Effects and animation8 lessons
- 86show, hide and toggleControl visibility with optional speed.
- 87FadingfadeIn, fadeOut, fadeToggle and fadeTo change opacity.
- 88SlidingslideUp, slideDown and slideToggle animate height.
- 89animateanimate changes numeric CSS properties over time.
- 90stop and delaystop halts animations and delay pauses the queue.
- 91Animation QueueAnimations queue in order on the same element.
- 92Effect CallbacksA callback runs after the effect finishes.
- 93CSS vs jQuery AnimationPrefer CSS transitions for simple effects and toggle a class.
Events and forms10 lessons
- 94click EventsAttach handlers with click and other shortcuts.
- 95on and offon attaches handlers and off removes them.
- 96The Event ObjectThe handler receives an event with target and coordinates.
- 97Event DelegationAttach one handler to a parent for dynamic children.
- 98Keyboard Eventskeydown, keyup and keypress respond to keys.
- 99Form Eventssubmit, change, focus, blur and input respond to forms.
- 100focus and blurRespond when an input gains or loses focus.
- 101trigger and custom eventstrigger fires an event in code.
- 102Simple Form ValidationCheck values and show errors.
- 103Mouse Eventsmouseenter, mouseleave, mousemove and contextmenu.
AJAX and utilities9 lessons
- 104loadload fetches HTML into an element.
- 105get and postShortcut methods for GET and POST.
- 106$.ajax$.ajax gives full control.
- 107getJSONgetJSON loads and parses JSON.
- 108Promises and DeferredAjax returns a promise like object.
- 109Utility Functions$.trim, $.isArray, $.extend and $.map help with data.
- 110noConflictRelease $ when another library uses it.
- 111data Methoddata stores values on elements.
- 112Storage and CookiesUse localStorage with jQuery for simple saving.
Plugins and practice12 lessons
- 113Writing a PluginExtend $.fn to add methods.
- 114jQuery UI IntrojQuery UI adds widgets like datepicker and sortable.
- 115Project: AccordionToggle panels with a click.
- 116Project: TabsSwitch visible panels with classes.
- 117Project: ModalOpen and close a dialog.
- 118Project: Todo ListAdd and remove items with delegation.
- 119Project: Live FilterFilter rows as you type.
- 120Performance TipsCache selectors, use delegation and avoid heavy loops.
- 121jQuery and Vanilla JSModern JavaScript covers many jQuery tasks.
- 122Project: Image SliderRotate images with a timer.
- 123Project: AJAX FormSubmit a form without reloading.
- 124Debugging jQueryCheck selections with length and console.