jaquer - hide if prev has class
Posted
by Tillebeck
on Stack Overflow
See other posts from Stack Overflow
or by Tillebeck
Published on 2010-03-08T12:27:01Z
Indexed on
2010/03/08
12:36 UTC
Read the original article
Hit count: 338
Hi
I would like to hide all class="csc-content" where previous sibling is a h4 class="faq".
UPDATE Error: I think this is wrong... the previous sibling is not h4. But I hope you get the point that all "answer" shall be hidden if the "question" has the class "faq" /UPDATE
This is the html:
<div id="centerCol-1">
<div id="c65" class="csc-default normal">
<div class="csc-header csc-header-n1"><h4 class="faq">FAQ question1</h4></div>
<div class="csc-content active"><p class="bodytext">Answer1</p></div>
</div>
<div id="c67" class="csc-default normal">
<div class="csc-header csc-header-n2"><h4 class="faq">FAQ question2</h4></div>
<div class="csc-content active"><p class="bodytext">Answer2</p></div>
</div>
<div id="c68" class="csc-default normal">
<div class="csc-header csc-header-n3"><h4>not FAQ</h4></div>
<div class="csc-content active"><p class="bodytext">Not an answer, just normal content</p></div>
</div>
</div>
jQuery should be something like:
// find all outer divs with class csc-default in the div centerCol-1
// test if they contain a header div with an h4 class faq
// go to next element and hide it. Error... this should be parents next element?
$("#centerCol-1 .csc-default").find("h4").is(".faq").next(".csc-content").hide();
BR. Anders
© Stack Overflow or respective owner