Convert string into jQuery object and select inner element

dom, html, javascript, jquery

Solution

This will create elements from the html and find the a1 element:

var element = $('<div id="a1"></div><div id="a3"></div>').filter('#a1').get(0);

Problem

I wonder if there is a way to convert string into jQuery object and select inner elements without injecting the whole string into DOM and manipulate it in there. Thanks. If possible, please give me example of converting ``` <div id=a1></div> <div id=a3></div> ``` And select a1 from the object variable.

Original source