2009-11-18 5 views
0

J'ai un menu de navigation qui une fois que l'utilisateur clique puis change et fondu le contenu. Le problème est que même le nœud enfant est devenu caché. Si je supprime tout le noeud enfant de mon ID div = "témoin" et id = "croire" alors cela fonctionne bien. Comment exclure le noeud enfant de div id = "witness" ou id = "believe"?jquery fondu contenu

Merci d'avance.

ici est mon javascript

$(function(){ 
    $("#content-linkwrap .hrefmenu").click(function(){ 

     $clicked = $(this); 
     // if the button is not already "transformed" AND is not animated 

      // each button div MUST have a "xx-button" and the target div must have an id "xx" 
      var idToLoad = $clicked.attr("id").split('-'); 

      //we search trough the content for the visible div and we fade it out 
      $("#description").find("div:visible").fadeOut("fast", function(){ 
       //once the fade out is completed, we start to fade in the right div 
       $(this).parent().find("#"+idToLoad[0]).fadeIn(); 
      }) 

    }); 
}); 

ici est mon html

<div align="center" id="content-linkwrap"><a href="#" class="link-black hrefmenu" id="witness-href">WITNESS</a><a href="#" class="link-black hrefmenu" id="believe-href">BELIEVE</a></div> 

     <div id="description"> 
      <div id="witness" class="desc">    
       <div class="top"><div class="bottom"><div class="left"><div class="right"><div class="bl"><div class="br"><div class="tl"><div class="tr"> 
        <div style="padding: 40px 20px;"> 
         <h3 class="text-orange">WITNESS</h3> 
         <p class="aboutus wpad10" align="justify">To a company that has initiated major retail projects representing more than US $10 million in investments. 
         </p> 
         <p class="aboutus" align="justify">To a conglomerate so solid and expansive with far-reaching business interests and investments in food service, real estate, electronics, heavy equipment, jewelry trading, travel, and hardware trading that spans the Philippines, Hong Kong, Singapore and Malaysia. </p>     
        </div>      
        <div class="clearleft"></div> 
       </div></div></div></div></div></div></div></div> 
      </div> 

      <div id="believe" class="desc">     
       <div class="top"><div class="bottom"><div class="left"><div class="right"><div class="bl"><div class="br"><div class="tl"><div class="tr"> 
        <div style="padding: 40px 20px;"> 
         <h3 class="text-orange">BELIEVE</h3> 
         <p class="aboutus wpad10" align="justify">In a corporation that toasts not only the successes – but also the opportunities. 
         </p> 
         <p class="aboutus wpad10" align="justify">In a business entity that puts a high premium on freedom and creative participation of its people at all levels…</p> 
         <p class="aboutus wpad10" align="justify">In a management that is committed to corporate expansion, to the personal growth of its people, and to partnerships and ventures that are mutually beneficial…</p>    
        </div>      
        <div class="clearleft"></div> 
       </div></div></div></div></div></div></div></div> 
      </div>              
     </div>  

Répondre

1

Actuellement, vous avez ce qui suit, où la découverte() correspond à tous les enfants « div » éléments même ceux imbriqués en profondeur sous l'élément « description »:

$("#description").find("div:visible").fadeOut(); 

Pour correspondre à peu les enfants immédiats de la ' élément « description qui sont visibles, vous pouvez utiliser ce code à la place:

$("#description").children().filter(":visible").fadeOut(); 

Pour plus d'informations, consultez le jQuery Traversing API documentation.

+0

salut matt, merci beaucoup. Cela fonctionne parfaitement. Je suis trop fier d'utiliser ce forum. – tirso

0

Si vous fade out un élément, puis tous son contenu sont fanées, donc il n'y a pas moyen d'exclure certains éléments enfants forment l'animation. Ma suggestion serait d'utiliser un sélecteur plus spécifique pour choisir les éléments que vous voulez vraiment faire disparaître.