If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

jQuery show/hide help

I have a question regarding jQuery show/hide.

At the moment, my page opens and my FAQs have all the answers showing. When I click on any of the questions, all the answers hide.

What adjustments can I make that will have my page open to only showing the questions (this is my FAQ page) and when a visitor clicks on a question, only that answer shows? Right now all answers show when I click a question.

Incidentally, I was recently asked to fix a website, the website has a lot of large images, the initial load took forever, the original developer made the same mistake, he did a preload of all images with $('img'), so all 200 or so images were loading when the page starts!!!!! It took >40sec to just for the front page to show up!!!!! :0

<html>
<head>
<title> Untitled </title>
<style type="text/css">
.active {color:red;};
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
// http://api.jquery.com/toggleClass/
// http://www.akifkaraagac.com/addclass-removeclass-toggleclass-jquery-css-isemleri/
$(document).ready(function(){
$(".hidden").hide();
$("h2.trigger").click(function(){
$(".hidden").hide();
$(this).next(".hidden").slideToggle("slow,");
});
});
</script>
</head>
<body>
<h2 class="trigger">The Time Through Ages</h2>
<div class="hidden">
In the Name of Allah, Most Gracious, Most Merciful
1. By the Time,
2. Verily Man is in loss,
3. Except such as have Faith, and do righteous deeds, and (join together) in the mutual enjoining of Truth, and of Patience and Constancy.
</div>
<h2 class="trigger">The Opening</h2>
<div class="hidden">
1. In the name of Allah, Most Gracious, Most Merciful.
2. Praise be to Allah, the Cherisher and Sustainer of the worlds;
3. Most Gracious, Most Merciful;
4. Master of the Day of Judgment.
5. Thee do we worship, and Thine aid we seek.
6. Show us the straight way,
7. The way of those on whom Thou hast bestowed Thy Grace, those whose (portion) is not wrath, and who go not astray.
</div>
</body>
</html>