2010-03-10 63 views
1

我为我的内容 div做了一个jQuery加载程序。但它不再显示我的div class="typeface"。这意味着我不能使用不同的字体。内容div的其余部分正常工作。谁能帮我?Div与字体JS不显示在可弹出的内容div

Javascript代码:(对于元素)

$(document).ready(function() { 

    // Check for hash value in URL 
    var hash = window.location.hash.substr(1); 
    var href = $('#nav li a').each(function(){ 
     var href = $(this).attr('href'); 
     if(hash==href.substr(0,href.length-5)){ 
      var toLoad = hash+'.html #content'; 
      $('#content').load(toLoad) 
     } 
    }); 

    $('#nav li a').click(function(){ 

     var toLoad = $(this).attr('href')+' #content'; 
     $('#content').hide('fast',loadContent); 
     $('#load').remove(); 
     $('#wrapper').append('<span id="load">LOADING...</span>'); 
     $('#load').fadeIn('normal'); 
     window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5); 
     function loadContent() { 
     $('#content').load(toLoad,'',showNewContent()) 
     } 
     function showNewContent() { 
     $('#content').show('normal',hideLoader()); 
     } 
     function hideLoader() { 
     $('#load').fadeOut('normal'); 
     } 
     return false; 

    }); 
}); 

HTML代码:

<body> 
<div id="wrapper"> 
    <ul id="nav"> 
     <li><a href="index.html">welcome</a></li> 
    </ul> 
     <div id="content"> 

     <div class="typeface-js" style="font-family: Helvetiker; color:#0182a8; font-size:25px; margin-bottom:10px;">Mauris ac eros. Donec quis lacus Header text. 
     </div> 

     Morbi gravida posuere est. Fusce id augue. More content text. 

     </div> 

</div> 

回答

0

.load将清除目标容器元素的全部内容(即:“#内容”)

<div id="content"> .... cleared ..... </div> 

因为你“字样-JS”元素包含在内容DIV,它被清除当你的负载完成。

0

你加载的东西完全超过了 '#内容' DIV,所以当然“字样,JS “div将消失(除非你用它加载它也有它)。你有看到?当你打电话

$('#content').load(...) 

然后无论在那<div>之前就会消失。