How bout doing $().toggle?

Also,

$("p").addClass("classname"); -- that will add a class.


badtant wrote:
> 
> hi! i have the following list:
> 
> <ul>
> <li>
> <h2>Kapitalförsäkring</h2>
> <p class="question">- q</p>
> <p class="answer">a</p>
> </li>
> 
> <li>
> <h2>Kapitalpension</h2>
> <p class="question">- q</p>
> <p class="answer">a</p>
> </li>
> </ul>
> 
> the class answer has the css "display:none". what i want to do with it is
> that when someone clicks a question the answer should be shown and all
> other answers should be hidden. to show an answer i have the class "show".
> i know how to remove the class from all answers with
> $("p.answer").removeClass("show"); but i don't know how to add the class
> again for the right answer. any idéas on this?
> 
> thanks!
> /niklas
> 

-- 
View this message in context: 
http://www.nabble.com/expand-one---collapse-the-others-tf2493260.html#a6954269
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to