2010-03-10 71 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>之前就會消失。