1

コンテンツdiv用に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>
4

2 に答える 2

0

.loadは、ターゲットコンテナ要素のコンテンツ全体をクリアします(例: "#content")

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

「typeface-js」要素はcontentdivに含まれているため、ロードが完了するとクリアされます。

于 2010-03-10T15:03:31.977 に答える
0

'#content' div の上に何かを完全にロードしているので、もちろん "typeface-js" div はなくなります (ロードしたものにそれが含まれていない限り)。見える?電話すると

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

その<div>前にあったものはすべてなくなります。

于 2010-03-10T14:55:20.053 に答える