Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
16
rated 0 times [  22] [ 6]  / answers: 1 / hits: 32812  / 15 Years ago, sat, november 28, 2009, 12:00:00

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.


More From » jquery

 Answers
48

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);

[#98204] Wednesday, November 25, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
melindab

Total Points: 511
Total Questions: 109
Total Answers: 106

Location: San Marino
Member since Thu, Jun 25, 2020
4 Years ago
;