<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".a_faq").each(function(i){
$(this).find(".question").click(function(){ $(this).find(".answer").show(); });
});
});
</script>
</head>
<body>
<div class="a_faq">
<div class="question">Where is everyone?</div>
<div style="display:none;" class="answer">there</div>
</div>
<div class="a_faq">
<div class="question">Where is the closest Starbucks</div>
<div style="display:none;" class="answer">there</div>
</div>
<div class="a_faq">
<div class="question">Where are my glasses?</div>
<div style="display:none;" class="answer">there</div>
</div>
</body>
</html>
After clicking the question I want the ability to show and hide the repesctive answer. If possible, close other answers that are open.
Im stuck at this point, and don’t know what to do.
That’s your click handler and all. No need for a loop.