quick jquery slide, universal event
<p>So i have to come up with some kind of mini script that behaves like this,</p>

<p>click a sentence, or a question, and the answer drops(slide down). click it again and it slides up etc..</p>

<p>simple enough....</p>

<p>Now im a noob so for example, if i have 1 questions, then of course ill write something like this:</p>

<p>css:</p>

<pre><code>.answer { display:none }
</code></pre>

<p>js/jQ:</p>

<pre><code>var question = $('.question');
var answer = $('.answer');

question.click( function(){
    answer.slideToggle(500);    
});
</code></pre>

<p>etc, but so now if i have say, 5 questions then ill have to create 5 more variables(or call em directly with jq) and etc etc...long story short, itll be code for <strong>EVERY</strong> question/answer set which will get <strong>unwieldy fast</strong></p>

<p>im trying to write something a bit smarter (and much less code) so to test my logic i try this:</p>

<pre><code>question.click( function(){
    if($(this).parent().hasClass('open')){
        $(this).parent().removeClass('open');
        alert("its open");  
    } else {
        alert("its not open");
        $(this).parent().addClass('open');

    }
});
</code></pre>

<p>now when i try this, it works. when its open it alerts open and removes the class open so on its next click, its not open and alerts me so aswell...so small test working.</p>

<p>So naturally this means i SHOULD be able to add SOME kind of animate/slide code to get me rolling and it SHOULD work but either A, it doesnt work, or B, it opens ALL the answers at the same time.</p>

<p>ive tried </p>

<pre><code>question.click( function(){
    if($(this).parent().hasClass('open')){
        $(this).parent().removeClass('open');
        //alert("its open");
        answer.slideUp(500);    
    } else {
        //alert("its not open");
        $(this).parent().addClass('open');

        answer.slideDown(500);
    }
});
</code></pre>

<p>and this one opens ALL the answers at the same time no matter what question i click on.</p>

<p>i figured, let me add a "this" to the answer line to localize the event...maybe something like.</p>

<pre><code>$(this).answer.slideDown(500);
</code></pre>

<p>but this plainly just doesnt work.</p>

<p>Ive also tried something like <code>$(this).find('answer').slideUp(500);</code></p>

<p>I KNOW im close lol. Any tips/links, explanations etc ill gladly appreciate.</p>

<p>Thanks in advanced.</p>
