Custom filters (Become an expert)

We've learned all of the available jQuery's filters. In some cases you may need a shortcut to collect elements for which jQuery doesn't provide a specific filter. This is exactly where custom filters come into play.

How to do it...

Our goal is to print the length of the elements having the placeholder attribute set, taking advantage of a previously created custom filter. In addition, to see all of the available options in action, we'll create a second filter to collect all of the elements having a name with less than a given number of characters.

To complete the task, follow these steps:

  1. Create a copy of the form-filters.html file and rename it as custom-filters.html.
  2. Edit the <head> section of the page, replacing ...

Get Instant JQuery Selectors now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.