Note that there are some explanatory texts on larger screens.

plurals
  1. POHide/show table columns with jQuery
    primarykey
    data
    text
    <p>I'm currently working on a new Magento template, and I'm facing problems with jQuery.</p> <p>My current code for app/design/frontend/default/blank/template/catalog/product/list.phtml is similar to follows (the page is hosted here: <a href="http://nordschleife.metaforix.net/118/118/index.php/panasonic.html" rel="nofollow noreferrer">http://nordschleife.metaforix.net/118/118/index.php/panasonic.html</a>)</p> <pre><code>&lt;table border="1"&gt; &lt;tr&gt; &lt;th width="178"&gt;Image&lt;/th&gt; &lt;th width="84"&gt;Order Code&lt;/th&gt; &lt;th width="84"&gt;Description&lt;/th&gt; &lt;th width="69"&gt;Cell Origin&lt;/th&gt; &lt;th width="98"&gt;Capacity (mAh)&lt;/th&gt; &lt;th width="110"&gt;&lt;p&gt;Price&lt;/p&gt; &lt;p&gt;&lt;?php echo $this-&gt;getChildHtml('currency2'); ?&gt;&lt;/p&gt;&lt;/th&gt; &lt;th width="39"&gt;Buy&lt;/th&gt; &lt;th width="131"&gt;Cell(s)&lt;/th&gt; &lt;th width="52"&gt;Voltage&lt;/th&gt; &lt;th width="49"&gt;Rating (Wh)&lt;/th&gt; &lt;th width="71"&gt;Part Number&lt;/th&gt; &lt;th id="chem" width="69"&gt;Chemistry&lt;/th&gt; &lt;th width="82"&gt;&lt;p&gt;Dimensions&lt;/p&gt; &lt;p&gt;(LxWxH)&lt;/p&gt;&lt;/th&gt; &lt;th width="52"&gt;Weight (g)&lt;/th&gt; &lt;th width="37"&gt;Color&lt;/th&gt; &lt;/tr&gt; &lt;?php $_iterator = 0; ?&gt; &lt;ol class="products-list" id="products-list"&gt; &lt;?php foreach ($_productCollection as $_product): ?&gt; &lt;tr&gt; &lt;td&gt; &lt;?php // Product Image ?&gt; &lt;/td&gt; &lt;td&gt; &lt;?php echo nl2br($_product-&gt;getSku()) ?&gt; &lt;/td&gt; &lt;td&gt; &lt;?php // Product description ?&gt; &lt;/td&gt; &lt;td&gt; &lt;?php echo $_product-&gt;getAttributeText('country') ?&gt; &lt;/td&gt; &lt;td&gt; &lt;?php echo $_product-&gt;getcapacity() ?&gt; &lt;/td&gt; &lt;td&gt; &lt;?php echo $this-&gt;getPriceHtml($_product, true) ?&gt; &lt;/td&gt; &lt;td&gt; &lt;?php //add to cart ?&gt; &lt;/td&gt; &lt;td&gt; &lt;?php echo $_product-&gt;getcells() ?&gt; &lt;/td&gt; &lt;td&gt; &lt;?php echo $_product-&gt;getvoltage() ?&gt; &lt;/td&gt; &lt;td&gt; &lt;?php echo $_product-&gt;getrating() ?&gt; &lt;/td&gt; &lt;td&gt; &lt;?php echo $_product-&gt;getmfgpartno(); ?&gt; &lt;/td&gt; &lt;td&gt; &lt;?php //chemistry ?&gt; &lt;/td&gt; &lt;td&gt; &lt;?php echo nl2br ($_product-&gt;getdimension()) ?&gt; &lt;/td&gt; &lt;td&gt; &lt;?php echo (int)$_product-&gt;getweight() ?&gt; &lt;/td&gt; &lt;td&gt; &lt;?php echo $_product-&gt;getAttributeText('color') ?&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/div&gt; &lt;?php endforeach; ?&gt; &lt;/table&gt; </code></pre> <p>I want to use jQuery to have a text on the page that allows the user to click and show/hide the last 5 columns of the table.</p> <p>I've place this in the file (wanted to try hiding 1 column first), but apparently it doesn't work:</p> <pre><code>&lt;script type="text/javascript"&gt; function show() { jQuery(".chem").show(); } function hide() { jQuery(".chem").hide(); } &lt;/script&gt; &lt;p&gt;&lt;div&gt; jQuery &lt;span onclick="show() "&gt;(More)&lt;/span&gt; &lt;span onclick="hide() "&gt;(Hide)&lt;/span&gt; &lt;/div&gt;&lt;/p&gt; </code></pre>
    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.
 

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