[jQuery] Re: Create array from li text

2009-04-06 Thread Ricardo
jQuery can parse it and create the elements without adding them to the DOM, then you can use Jack's suggestion: var arr = []; $(yourHTMLstring).find('li').each(function(){ arr.push( $(this).text() ); }); - ricardo On Apr 6, 2:48 pm, Nic Hubbard wrote: > Yeah, I had thought of the hidden di

[jQuery] Re: Create array from li text

2009-04-06 Thread Jack Killpatrick
d'oh, I just realized you have the html in a var... I s'pose a "cheat" would be to add them to a hidden UL and then do something like the below so you could take advantage of the .text() and .each() method. Other than that, I'm not sure of the regex offhand to split the LI's and parse out the

[jQuery] Re: Create array from li text

2009-04-06 Thread Nic Hubbard
Yeah, I had thought of the hidden div idea, and placing the html into that, then using .each(). I just wondered if there was a method to do it without adding the content to the DOM. On Apr 6, 10:35 am, Jack Killpatrick wrote: > d'oh, I just realized you have the html in a var... > > I s'pose a

[jQuery] Re: Create array from li text

2009-04-06 Thread Jack Killpatrick
maybe something like this: var ar = []; $('#yourList li').each(function(){ ar.push( $(this).text() ); }); - Jack Nic Hubbard wrote: A better explanation: I have a var that contains some html. Within that there are elements that I need to strip the text out of and put that into an array.

[jQuery] Re: Create array from li text

2009-04-06 Thread Nic Hubbard
A better explanation: I have a var that contains some html. Within that there are elements that I need to strip the text out of and put that into an array. How would I do this? I figure I could use each() and push(), but I am not sure how to do this grabbing it from a var. On Apr 5, 11:30 pm