Trying to create collapsible / expandable divs using jQuery, but it's not working for me at all... Each h3 should expand/collapse the div beneath it, and I'm not sure why this isn't working... Granted, is a heavily nested div, but I thought that the script below would find the uforms class regardless of how much other markup is on the page when it loads and then do what it's supposed to do...
Here's the jquery:
$(document).ready(function () {
$('div.uforms:eq(1)> div:gt(-1)').hide();
$('div.uforms:eq(1)> h3').click(function() {
$(this).next('div:hidden').slideDown('fast').siblings('div:visible').slideUp('fast');
});
});
And, the markup (minus all the stuff that's actually inside the <div></div>
, because it's a lot of form stuff...)
<div class="uforms">
<h3>Heading</h3>
<div></div>
<h3>Heading</h3>
<div></div>
<h3>Heading</h3>
<div></div>
</div>