Working with empty jQuery objects to build dynamic selectors
Last updated • October 15th, 2019
This is one of those techniques that you don’t really think you need until you find yourself in a situation where you do. This definitely isn’t a hammer and more often than not, you can select what you need in a single selector via jQuery or through the use of the built-in .filter() method but when writing more complex jQuery, this technique can come in handy.
The technique I’m referring to is the ability to kick off with an empty jQuery object and build it up dynamically. It’s not something I use very often but it has come in handy so I figure I’d throw up an example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters