Note that there are some explanatory texts on larger screens.

plurals
  1. POReorderTable rows with jQuery but exclude the nested tables
    primarykey
    data
    text
    <p>I'm trying to exclude nested tables/tr from my Reorder Table script. I have looked at the topic of JQuery and nest tables. Everything I try only work half way. $("#table tr.table_row1") or $("table > tr.order_rows")</p> <p>it's in a for loop and picks up the order from an array. I would appreciate any help.</p> <p>Heres' my code:</p> <pre><code> &lt;table&gt; &lt;tr class="order_rows"&gt; &lt;- pick this row &lt;td&gt; &lt;table&gt; &lt;tr&gt; &lt;- dont pick this &lt;td&gt;&lt;input type="text" name="order1" value="1" id="order1" size="2" /&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;- dont pick this row &lt;td&gt;...&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr class="order_rows"&gt; &lt;- pick this row &lt;td&gt; &lt;table&gt; &lt;tr&gt; &lt;- dont pick this row &lt;td&gt;&lt;input type="text" name="order1" value="1" id="order1" size="2" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;- dont pick this row &lt;td&gt;...&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>This is my JQuery that I'm working on. </p> <pre><code> function reorder(NewOrder) { var orderedTrs = new Array(); alert(NewOrder); for ( i=0; i&lt;=NewOrder.length; i++ ) orderedTrs[i] = $("#table tr")[NewOrder[i]]; alert(orderedTrs); for ( i=0; i&lt;=NewOrder.length; i++ ) $("#table").append(orderedTrs[i]); } $(document).ready(function() { $(".updateButton:button").click(function() { var NewOrder = new Array; NewOrder[0] = parseInt($("#order1").val()); NewOrder[1] = parseInt($("#order2").val()); reorder(NewOrder); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
 

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