<p>I have a structure like this:</p>

<pre><code>&lt;ul&gt;
  &lt;li&gt;text1&lt;/li&gt;
  &lt;li&gt;text2&lt;/li&gt;
  &lt;li&gt;text3&lt;/li&gt;
&lt;/ul&gt;
</code></pre>

<p>How do I use javascript or jQuery to get the text as an array?</p>

<pre><code>['text1', 'text2', 'text3']
</code></pre>

<p>My plan after this is to assemble it into a string, probably using <code>.join(', ')</code>, and get it in a format like this:</p>

<pre><code>'"text1", "text2", "text3"'
</code></pre>

```
```
var optionTexts = [];
$("ul li").each(function() { optionTexts.push($(this).text()) });
```
```
...should do the trick. To get the final output you're looking for,
```
join()
```
plus some concatenation will do nicely:
```
```
var quotedCSV = '"' + optionTexts.join('", "') + '"';
```
```