// note this array has outer scope var phrases = []; $('.phrase').each(function(){ // this is inner scope, in reference to the .phrase element var phrase = ''; $(this).find('li').each(function(){ // cache jquery var var current = $(this); // check if our current li has children (sub elements) // if it does, skip it // ps, you can work with this by seeing if the first child // is a UL with blank inside and odd your custom BLANK text if(current.children().size() > 0) {return true;} // add current text to our current phrase phrase += current.text(); }); // now that our current phrase is completely build we add it to our outer array phrases.push(phrase); }); // note the comma in the alert shows separate phrases alert(phrases);
A round of applause for your blog post.Thanks Again. Keep writing.
Hey, thanks for the post.Really thank you! Cool.
Im grateful for the blog post.Much thanks again. Great.
A round of applause for your article.Really looking forward to read more. Great.
I value the blog article.Thanks Again. Cool.
I really like and appreciate your post.Really thank you! Keep writing.
Thanks on your marvelous posting! I genuinely enjoyed reading it, you will be a great author.