Note that there are some explanatory texts on larger screens.

plurals
  1. POHide table row based on content of table cell
    primarykey
    data
    text
    <p>I want to make some jQuery that shows some table rows and hides others based on the content of the first table cell in each row.</p> <p>When I click a list item I want jQuery to check if the first letter of the item matches the first letter in any table cell in my markup, if so the parent table row should be shown and other rows should be hidden.</p> <p>This is my markup:</p> <pre><code>&lt;ul&gt; &lt;li&gt;A&lt;/li&gt; &lt;li&gt;B&lt;/li&gt; &lt;li&gt;G&lt;/li&gt; &lt;/ul&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Alpha1&lt;/td&gt; &lt;td&gt;Some content&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Alpha2&lt;/td&gt; &lt;td&gt;Some content&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Alpha3&lt;/td&gt; &lt;td&gt;Some content&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Beta1&lt;/td&gt; &lt;td&gt;Some content&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Beta2&lt;/td&gt; &lt;td&gt;Some content&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Beta3&lt;/td&gt; &lt;td&gt;Some content&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Gamma1&lt;/td&gt; &lt;td&gt;Some content&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Gamma2&lt;/td&gt; &lt;td&gt;Some content&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Gamma3&lt;/td&gt; &lt;td&gt;Some content&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>So if I press "A" this is what is rendered in the browser:</p> <pre><code>&lt;ul&gt; &lt;li&gt;A&lt;/li&gt; &lt;li&gt;B&lt;/li&gt; &lt;li&gt;G&lt;/li&gt; &lt;/ul&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Alpha1&lt;/td&gt; &lt;td&gt;Some content&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Alpha2&lt;/td&gt; &lt;td&gt;Some content&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Alpha3&lt;/td&gt; &lt;td&gt;Some content&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>I'm really new to jQuery so any hint on how to go about a problem like this would be appreciated :)</p>
    singulars
    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.
    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