Note that there are some explanatory texts on larger screens.

plurals
  1. POClient side Sorting inside < li> tag values
    primarykey
    data
    text
    <p>I have a HTML like this</p> <pre><code>&lt;div&gt; &lt;ul id="ulId"&gt; &lt;li id="liId1"&gt; &lt;span id="spn1-Li1"&gt;YVariable1&lt;/span&gt; &lt;span id="spn2-Li1"&gt;XVariable2&lt;/span&gt; &lt;span id="spn3-Li1"&gt;ZVariable3&lt;/span&gt; &lt;/li&gt; &lt;li id="liId2"&gt; &lt;span id="spn1-Li2"&gt;ZVariable1&lt;/span&gt; &lt;span id="spn2-Li2"&gt;YVariable2&lt;/span&gt; &lt;span id="spn3-Li2"&gt;XVariable3&lt;/span&gt; &lt;/li&gt; &lt;li id="liId3"&gt; &lt;span id="spn1-Li3"&gt;XVariable1&lt;/span&gt; &lt;span id="spn2-Li3"&gt;ZVariable2&lt;/span&gt; &lt;span id="spn3-Li3"&gt;YVariable3&lt;/span&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>The view has like this</p> <pre><code>YVariable1 XVariable2 ZVariable3 ZVariable1 YVariable2 XVariable3 XVariable1 ZVariable2 YVariable3 </code></pre> <p>But I need to sort the result based on the first span value, the remaining "&lt; li>" should be same. Means the result should be as following on click of "sort by button".</p> <pre><code> XVariable1 ZVariable2 YVariable3 YVariable1 XVariable2 ZVariable3 ZVariable1 YVariable2 XVariable3 </code></pre> <p>I need this in client side (javascript or jQuery). I have tried in multiple ways, But I didn't get what I'm expecting.</p> <p>This code I have now, and same altered similar ways </p> <pre><code>$('#btnOrderBy').click(function () { var data = []; $('#ulId li').each(function (item, value) { $('span', value).each(function (i, v) { data.push($(this).text()); }); }); console.log(data.sort()); }); </code></pre>
    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.
 

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