Featured post
javascript - jQuery not doing what I want it to do -
i'm having trouble little jquery, , thought in community me out? so, markup follows:
<div class="left"> <ul id="editing-nav"> <li><a class="active testforso" href="#testforso">test so</a></li> <li><a class="testforso2" href="#testforso2">test so2</a></li> ...and on. </ul> </div> <div class="scroll"> <div class="scrollcontainer"> <div id="testforso"> ...some content </div> <div id="testforso2"> ...some content </div> ...and on. </div> </div>
so, - .left floated left, , .scroll on right side. looking way active nav element (by default, first one, , when user click one, it'd assign element class of ".active" , remove previous one's active class)'s co-insiding div has display:block, while others hide. i'm doing inside of fancybox, makes little bit more complicated, here's have -
$('#editing-nav li > a').click(function() { $('#editing-nav li > a').removeclass('active'); $(this).addclass('active'); activeclassid = $(this).attr('class'); // grabs nav class id show in .scroll var dividtoshow = ('.scroll .scrollcontainer #') + activeclassid; // grabs dom path & id of coinciding div show dividtoshow = dividtoshow.replace(' active', ''); // removes " active" class (because before have class of "testforso2 active"; has "testforso". $('.scrollcontainer div:not(#' + dividtoshow + ')').hide(); $('.scrollcontainer #' + dividtoshow ).show(); });
this works first link clicks, not after that. don't know if clear earlier, class #editing-nav li co-incides div show inside of .scroll.
any ideas? i'm not sure why it's doing this... thank you!
this issue id selector - try this instead
edit
figured out real issue here - not sure why works first time dividtoshow
variable contains information. see here cut down version
- Get link
- X
- Other Apps
Comments
Post a Comment