Introduction to Effects

link Showing and Hiding ContentjQuery can show or hide content instantaneously with .show() or .hide(): 1 2 3 4 5 // Instantaneously hide all paragraphs$( "p" ).hide(); // Instantaneously show all divs that have the hidden style class$( "div.hidden" ).show(); When jQuery hides an element, it sets its CSS display property to none. This means … Continue reading

Iterating over jQuery and non-jQuery Objects

jQuery provides an object iterator utility called $.each() as well as a jQuery collection iterator: .each(). These are not interchangeable. In addition, there are a couple of helpful methods called $.map() and .map() that can shortcut one of our common iteration use cases. link $.each()$.each() is a generic iterator function for looping over object, arrays, … Continue reading

Style Guide

link Formatting ConventionsArticles in the learn site are authored with GitHub Flavored Markdown, and the beginning of each article contains some JSON "front matter" that contains metadata used when the article is published. link Article Header MetadataEach article should have the following header (see below as some metatags are optional): 1 2 3 4 5 … Continue reading

How jQuery Works

link jQuery: The BasicsThis is a basic tutorial, designed to help you get started using jQuery. If you don't have a test page setup yet, start by creating the following HTML page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 <!doctype html><html><head> <meta charset="utf-8"> <title>Demo</title></head><body> <a href="http://jquery.com/">jQuery</a> … Continue reading

Introducing Events

link IntroductionWeb pages are all about interaction. Users perform a countless number of actions such as moving their mice over the page, clicking on elements, and typing in textboxes — all of these are examples of events. In addition to these user events, there are a slew of others that occur, like when the page … Continue reading

Utility Methods

jQuery offers several utility methods in the $ namespace. These methods are helpful for accomplishing routine programming tasks. For a complete reference on jQuery utility methods, visit the utilities documentation on api.jquery.com. Below are examples of a few of the utility methods: link $.trim()Removes leading and trailing whitespace: 1 2 // Returns "lots of extra … Continue reading

jQuery’s Ajax-Related Methods

While jQuery does offer many Ajax-related convenience methods, the core $.ajax() method is at the heart of all of them, and understanding it is imperative. We'll review it first, and then touch briefly on the convenience methods. It's often considered good practice to use the $.ajax() method over the jQuery provided convenience methods. As you'll … Continue reading

Handling Events

jQuery provides a method .on() to respond to any event on the selected elements. This is called an event binding. Although .on() isn't the only method provided for event binding, it is a best practice to use this for jQuery 1.7+. To learn more, read more about the evolution of event binding in jQuery. The … Continue reading

About This Site

Learning how and when to use jQuery is a different process for each and every web developer, depending largely on experience with the primary tools for front-end development (HTML, CSS, and JavaScript) and knowledge of general programming principles. Over the years developers of all stripes have come to rely on our API documentation for help … Continue reading

Creating a Custom Theme with ThemeRoller

link Theming OverviewjQuery Mobile has a robust theme framework that supports up to 26 sets of toolbar, content, and button colors, called a "swatch". The framework comes with five defined themes (swatches "a" to "e") which can be used readily, removed, or overwritten. link Default Theme Swatch Mapping for ComponentsIf no theme swatch letter is … Continue reading

Getting Started with jQuery Mobile

jQuery Mobile provides a set of touch-friendly UI widgets and an Ajax-powered navigation system to support animated page transitions. This guide will show you how you can build your first jQuery Mobile application. link Create a Basic Page TemplateTo get started, you can simply paste the template below in your favorite text editor, save, and … Continue reading

Understanding Event Delegation

link IntroductionEvent delegation allows us to attach a single event listener, to a parent element, that will fire for all descendants matching a selector, whether those descendants exist now or are added in the future. link ExampleFor the remainder of the lesson, we will reference the following HTML structure: 1 2 3 4 5 6 … Continue reading

Additional jQuery Support

While we hope to cover most jQuery-related topics on this site, you may need additional or more immediate support. The following resources can prove useful. link Official Forumshttp://forum.jquery.com/ There are many subforums where you can discuss jQuery, ask questions, talk about JavaScript, or announce your plugins. Getting Started This is the best place to post … Continue reading

Avoiding Conflicts with Other Libraries

The jQuery library and virtually all of its plugins are contained within the jQuery namespace. As a general rule, global objects are stored inside the jQuery namespace as well, so you shouldn't get a clash between jQuery and any other library (like prototype.js, MooTools, or YUI). That said, there is one caveat: by default, jQuery … Continue reading

Theming jQuery UI

All jQuery UI plugins are designed to allow a developer to seamlessly integrate UI widgets into the look and feel of their site or application. Each plugin is styled with CSS and contains two layers of style information: standard jQuery UI CSS Framework styles and plugin-specific styles. The jQuery UI CSS Framework provides semantic presentation … Continue reading

Deferred examples

link Further Deferreds examplesDeferreds are used behind the hood in Ajax but it doesn't mean they can't also be used elsewhere. This section describes situations where deferreds will help abstract away asynchronous behavior and decouple our code. link Cachinglink Asynchronous cacheWhen it comes to asynchronous tasks, caching can be a bit demanding since you have … Continue reading

Custom Effects with .animate()

jQuery makes it possible to animate arbitrary CSS properties via the .animate() method. The .animate() method lets you animate to a set value, or to a value relative to the current value. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 // Custom effects with .animate()$( "div.funtimes" ).animate( { … Continue reading

$( document ).ready()

A page can't be manipulated safely until the document is "ready." jQuery detects this state of readiness for you. Code included inside $( document ).ready() will only run once the page Document Object Model (DOM) is ready for JavaScript code to execute. Code included inside $( window ).on( "load", function() { … }) will run … Continue reading

Ajax

Traditionally webpages required reloading to update their content. For web-based email this meant that users had to manually reload their inbox to check and see if they had new mail. This had huge drawbacks: it was slow and it required user input. When the user reloaded their inbox, the server had to reconstruct the entire … Continue reading

Using jQuery UI with AMD

Note: This documentation refers to functionality made available in jQuery UI 1.11. As of jQuery UI 1.11, all of the library's source files support using AMD. This means that you can manage your jQuery UI dependencies without using Download Builder, and load jQuery UI's source files asynchronously using an AMD loader such as RequireJS. In … Continue reading