Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Using <code>.map()</code> with <code>.get()</code> is one way to go:</p> <pre><code>var arr = $(value).map(function() { var $th = $(this); if($th.is("TD")) return $th.html(); }).get(); alert(arr); </code></pre> <p>I'm not sure what <code>value</code> represents, but if you change the selector to match only <code>td</code> elements, you could simplify the return statement with <code>return $(this).html();</code>. </p> <p><code>.map()</code> iterates over the elements, and adds the return value to the jQuery object. <code>.get()</code> retrieves just the array out of the jQuery object.</p> <ul> <li><a href="http://api.jquery.com/map/" rel="nofollow noreferrer">http://api.jquery.com/map/</a></li> <li><a href="http://api.jquery.com/get/" rel="nofollow noreferrer">http://api.jquery.com/get/</a></li> </ul> <hr> <p>Sounds like <code>value</code> is a <code>tr</code>. Then you could do this:</p> <pre><code>var arr = $(value).children('td').map(function() { return $(this).html(); }).get(); alert(arr); </code></pre> <hr> <p>To create an array with each item containing an array of that row's <code>td</code> element's html, you could do this:</p> <pre><code>var arr = []; $('tr').each(function() { arr.push($(this).children('td').map(function() { return $(this).html(); })); }).get(); console.log(arr); </code></pre> <p>This uses the standard <code>.push()</code> since I don't think that using <code>.map()</code> inside <code>.map()</code> would work. I think when you pass the inner array into the jQuery object, it just adds it to the main array (or something).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload