$ vs $()

Until now, we’ve been dealing entirely with methods that are called on a jQuery object. For example: 1 $( “h1” ).remove(); Most jQuery methods are called on jQuery objects as shown above; these methods are said to be part of the $.fn namespace, or the “jQuery prototype,” and are best thought of as jQuery object … 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

Advanced Plugin Concepts

link Provide Public Access to Default Plugin SettingsAn improvement we can, and should, make to the code above is to expose the default plugin settings. This is important because it makes it very easy for plugin users to override/customize the plugin with minimal code. And this is where we begin to take advantage of the … 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

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

Extending Widgets with the Widget Factory

jQuery UI’s widget factory makes it easy to build widgets that extend the functionality of existing widgets. Doing so allows you to build powerful widgets on top of an existing base, as well as make small tweaks to an existing widget’s functionality. Note: This article assumes some basic knowledge of what the widget factory is … Continue reading

How To Use the Widget Factory

While most existing jQuery plugins are stateless – that is, we call them on an element and that is the extent of our interaction with the plugin – there’s a large set of functionality that doesn’t fit into the basic plugin pattern. In order to fill this gap, jQuery UI has implemented a more advanced … 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

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

jQuery Event Basics

link jQuery Event Basicslink Setting Up Event Responses on DOM ElementsjQuery makes it straightforward to set up event-driven responses on page elements. These events are often triggered by the end user’s interaction with the page, such as when text is entered into a form element or the mouse pointer is moved. In some cases, such … Continue reading