Javascript show div when button is clicked <p>I realize that this is a common question and I have searched for solutions and the one that I'm trying to use (it works in jsfiddle) but when I tried to use it in my website it just won't work. I'm trying to show a div when a button is clicked. Am I doing something wrong? Maybe there's something wrong with the javascript? Or could it be I need to include a jquery js file? Thanks for your help in advance.</p> <p>Here is the code I'm trying to use:</p> <pre><code>&lt;script type="text/javascript"&gt; $("#seeAnswer").click(function() { $('#subtext').html($(this).next().html()); }); &lt;/script&gt; </code></pre> <p>And I'm trying to use it with this:</p> <pre><code>&lt;div class="back_button"&gt; &lt;button id="seeAnswer"&gt;See Answer&lt;/button&gt; &lt;/div&gt; &lt;span&gt; &lt;?php /* foreach($row2 as $ans) { $answer = $ans['answer']; } echo $answer; echo "hi"; */ ?&gt; &lt;?php foreach ($row2 as $ans) : ?&gt; &lt;p&gt;&lt;?php htmlspecialchars($ans['answer']) ?&gt;&lt;/p&gt; &lt;?php endforeach ?&gt; &lt;p&gt;hi there&lt;/p&gt; &lt;/span&gt; &lt;div id="subtext"&gt; &lt;/div&gt; </code></pre>