I’m new to jquery and have written the following code to toggle between content divs for a page I’m designing. I want the three content divs to be hidden by default and then if a header is clicked I want that content div to be visible. I want the divs to close automatically if a different header is clicked so only one is visible at a time.
I thought this code would work but it doesn’t seem to be for some reason.
Code:
<head>
<script type="text/javascript" language="javascript">
$('document').ready(function(){
$('#partnersContent').hide();
$('#companyContent').hide();
$('#investmentsContent').hide();
$('#partnersHeader').click(function(){
$('#partnersContent').slideToggle('1000');
$('#companyContent').hide('bind');
$('#investmentsContent').hide('bind');
});
$('#companyHeader').click(function(){
$('#companyContent').slideToggle('1000');
$('#partnersContent').hide('bind');
$('#investmentsContent').hide('bind');
});
$('#investmentsHeader').click(function(){
$('#investmentsContent').slideToggle('1000');
$('#companyContent').hide('bind');
$('#partnersContent').hide('bind');
});
});
</script>
</head>
<body>
<div id='partners'>
<div id='partnersHeader'>Partners</div>
<div id='partnersContent'>Information about partners</div>
</div>
<div id='company'>
<div id='companyHeader'>Company</div>
<div id='companyContent'>Information about company</div>
</div>
<div id='investments'>
<div id='investmentsHeader'>Investments</div>
<div id='investmentsContent'>Information about investments</div>
</div>
</body>
</html>
Based on your source, and the fact that it did work in my fiddle (http://jsfiddle.net/GjuYK/1/)
I would guess you forgot