First, I would suggest the following structure for your faq:
<div id="faq">
<div class="qa" id="faq_greenandflies">
<span class="q">What is <a href="#faq_greenandflies">green and flies</a></span>
<div class="a">
Super Pickle!
</div>
</div>
<div class="qa" id="faq_redandbadforteeth">
<span class="q">What is <a href="#faq_redandbadforteeth">Red and bad for your teeth</a></span>
<div class="a">
a Brick
</div>
</div>
</div>
and then define your jQuery as follows:
<script type="text/javascript">
$(function(){
$('div#faq .qa .a').hide();
$('div#faq .qa .q a').bind(
'click',
function(e){
$(this).parents('.qa').siblings().children('.a').slideUp();
$(this).parents('.qa').children('.a').slideDown();
return true;
});
$(location.hash).find('.q a').click();
});
</script>
Explanation:
(ex .1)
- This is the link that was clicked.
- , , "qa" (, , )
- . ( qa jQ)
(Ex.2)
A .
: