Working with empty jQuery objects to build dynamic selectors

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.

One last thing…

If you liked this article, I'd be incredibly grateful if you tweeted about it.

Also, I don't send emails often but when I do, I try to fill them full of useful goodies. If you like code snippets & dev tips, join my mailing list. There's no catch but I'll probably want to tell you about any new plugins & tools I build.