Note that there are some explanatory texts on larger screens.

plurals
  1. POshow/hide rows with special conditions
    primarykey
    data
    text
    <p>I have a table with this markup:</p> <pre><code>&lt;table&gt; &lt;tr class="odd"&gt;&lt;td&gt;Product 1&lt;/td&gt;&lt;/tr&gt; &lt;tr class="even"&gt;&lt;td&gt;Product 2&lt;/td&gt;&lt;/tr&gt; &lt;tr class="odd"&gt;&lt;td&gt;Product 3&lt;/td&gt;&lt;/tr&gt; &lt;tr class="even"&gt;&lt;td&gt;Product 4&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Every table row is a product and some products have more information. So in this case a table looks like this:</p> <pre><code>&lt;table&gt; &lt;tr class="odd"&gt;&lt;td&gt;Product 1&lt;/td&gt;&lt;/tr&gt; &lt;tr class="even"&gt;&lt;td&gt;Product 2&lt;/td&gt;&lt;/tr&gt; &lt;tr class="even"&gt;&lt;td&gt;Information 1&lt;/td&gt;&lt;/tr&gt; &lt;tr class="even"&gt;&lt;td&gt;Information 2&lt;/td&gt;&lt;/tr&gt; &lt;tr class="odd"&gt;&lt;td&gt;Product 3&lt;/td&gt;&lt;/tr&gt; &lt;tr class="even"&gt;&lt;td&gt;Product 4&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; </code></pre> <p>I wan't to hide the rows with the product information, and show it after a click on the product row.</p> <p>I tried this with the following Javascript function and onlick="":</p> <pre><code>function showHide(id) { var el = document.getElementById(id); if( el &amp;&amp; el.style.visibility == 'hidden') el.style.visibility = 'visible'; else el.style.visibility = 'hidden'; } </code></pre> <p>But the problem is I don't know how to target only the information rows of the product I've clicked on. It would be easy if I could change the markup, but this markup is generated, so I only can solve it with Javascript.</p> <p>Is ist possible to solve this problem? I have created a fiddle, so it's easier to deliver a quick solution:</p> <p><a href="http://jsfiddle.net/emjay__/8B3M4/" rel="nofollow">http://jsfiddle.net/emjay__/8B3M4/</a></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