我制成一个jQuery装载机为我的含量格。但现在不显示我的div class="typeface"。这意味着我不能使用不同的字体。内容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>
有帮助吗?

解决方案

.load将清除该目标容器元件的整个内容(即:“#内容”)

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

,因为你的“字体-JS”元素被包含在内容的div,它正在你的加载完成时清零。

其他提示

您正在加载的东西完全超过了“#内容” DIV,所以当然“字样-JS”的div将会消失(除非你用也加载它,在它)。你有看到?当你调用

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

那么无论是在<div>之前将不复存在。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top