Hide all instances of a tag using jQuery <p>I want to "play" with jQuery's <code>hide()</code> function on a blog that I have and I want to make it so that clicking a button will hide all "cake names" on my page. I don't really know how to do that because I'm a beginner in jQuery. Can somebody help me, please? My code is:</p> <pre><code>&lt;?php @include APP_PATH . '/view/snippets/header.tpl.php'; ?&gt; &lt;h2&gt;Our cakes&lt;/h2&gt; &lt;script&gt; $(document).ready(function(){ $("button").click(function(){ $("h2").hide(); }); }); &lt;/script&gt; &lt;?php if ($cakes) : ?&gt; &lt;ol&gt; &lt;?php foreach ($cakes as $cake) : ?&gt; &lt;li&gt; &lt;h3&gt;&lt;?php echo $cake-&gt;name; ?&gt;&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;&lt;b&gt;Quantity:&lt;/b&gt; &lt;?php echo $cake-&gt;quantity ?&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="&lt;?php echo APP_URL ?&gt;cake/view/&lt;?php echo $cake-&gt;id ?&gt;"&gt;View&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;?php endforeach; ?&gt; &lt;/ol&gt; &lt;body&gt; &lt;button&gt;Click me&lt;/button&gt; &lt;/body&gt; &lt;?php else : ?&gt; &lt;p&gt;Sorry, no sugar for you, babyyy!!&lt;/p&gt; &lt;?php endif; ?&gt; &lt;?php @include APP_PATH . '/view/snippets/footer.tpl.php'; ?&gt; </code></pre> <p>I tried something but it doesn't work.</p>