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
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
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
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.
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
5 matches
Mail list logo