I have several divs for displaying demo boxes of graphics, and code boxes for displaying sample code for using the graphics. What I want to do is make the code boxes invisible until you click on the demo box - which should make the code box slide into view. (See here to see how it looks)
This should be super simple with jQuery, as I've done it several times before, but for some reason I can't seem to get it to work this time.
Here's a shortened version of my code.
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
//hide the all of the element with class code-*
//$(".code-left").hide();
//$(".code-right").hide();
-->
//toggle the component with the respective class
$(".demobox-dark").click(function()
{
$(this).next(".code-left").slideToggle(600);
});
$(".demobox-light").click(function()
{
$(this).next(".code-right").slideToggle(600);
});
});
</script>
<div class="demobox-light">
<div class="color_blacktext"> </div>
<p>Black text</p>
</div>
<div class="demobox-dark">
<div class="color_whitetext"> </div>
<p>White text</p>
</div>
<p>Code:</p>
<div class="code-left">
<p class="code">TEXT</p>
</div>
Can anyone spot the error? Cause I sure can't. Then again, I'm definitely no JavaScript wizard.