javascript - How do I fade in a div by id if cookie=1? -


i have page few tabs. looking way if select tab 5 , cookie = 1 show tab6 otherwise show tab5.

the code tabs is:

jquery(".tabs a").click(function () {     stringref = jquery(this).attr("href").split('#')[1];     jquery('.tab_content:not(#' + stringref + ')').hide();     jquery('.tab_content#' + stringref).fadein();     return false; }); 

i want tab number 5, if clicked , cookie=1 show tab6. code shows div5 or div6 if cookie 1 or null is:

alreadyclosed = $.cookie(statecookiename);  if (alreadyclosed != 1) {     $div5.show();     $div6.hide(); } else {     $div5.hide();     $div6.show(); } 

how add them together? assume should way say:

if tab1.click , cookie = 1 show $div1 else tab1.click , cookie = null show $div2 

the body looks like:

<!-- buttons --> <ul id="boxes" class="tabs"> <li><a href="#div5">div 5</a></li> <li><a href="#div6">div 6</a></li> </ul>  <!-- content --> <div class="tab_content" id="div5">div 5</div> <div class="tab_content" id="div6">div 6</div> 

i hope guys can me. alot & regards, rallyboy.

jquery(".tabs a").click(function () {     alreadyclosed = $.cookie(statecookiename);      stringref = jquery(this).attr("href").split('#')[1];      if(alreadyclosed == 1)     {         newstring = stringref;         if(stringref == "5")         {             newstring = "6";         }         elseif(stringref == "6")         {             newstring = "5";         }         stringref = newstring;     }      jquery('.tab_content:not(#' + stringref + ')').hide();     jquery('.tab_content#' + stringref).fadein();     return false; }); 

this code quick check - if cookie set, toggles 5 6 or 6 5. proceeds normal.

do need more general solution tabs 5 , 6? if so, can please lay out rules how should work?


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -