HeroFromYesterday
New Member
I am trying to run down a \[code\]UL\[/code\] set:\[code\]<ul> <li> <h2>Header 1</h2> <ul class="collapse"> <li>A</li> <li>B</li> <li>C</li> <li>D</li> <li>E</li> </ul> </li> <li> <h2>Header 2</h2> <ul class="collapse"> <li>A</li> <li>B</li> <li>C</li> <li>D</li> <li> <h2>Header 3</h2> <ul class="collapse"> <li>A</li> <li>B</li> <li>C</li> <li>D</li> <li> <h2>Header 4</h2> <ul class="collapse open"> <li>A</li> <li>B</li> <li>C</li> <li>D</li> <li>E</li> </ul> </li> </ul> </li> </ul> </li></ul>\[/code\]Where if I find one of the children with the class \[code\]open\[/code\] I want to remove the class \[code\]collapse\[/code\] and/or \[code\]open\[/code\] from any parent level UL's prior to that child found with \[code\]open\[/code\]. Maybe I'm to tired, but I have this seriously flawed logic, in my head I am trying to make sense of it, at the same time I feel its not logical, and theres bound to be an easier way to do this. (Mind you the \[code\]$.each()\[/code\] I am currently attempting is flawed and doesnt work anyway). But I could use some ideas how to approach this if anyones go some.\[code\]$('ul').each(function(){ if($(':notfirst)', this)) { if($(this).hasClass('collapse')) { alert('collapse found'); $kid = $(this).child('ul'); if($kid.hasClass('open')) { alert('uh') $kid.parents('ul').removeClass('collapse'); } } }});\[/code\]