2011-09-13 7 views
0

要素を複製して古いものを削除しようとしていますが、IEでZ-インデックスの問題があり、条件付きコメントを使用してこれを行うためです。html要素を#divからbody構文に移動する

<!--[if lte IE 7]> 
<script type="text/javascript"> 
    $(document).ready(function() { 
      var callCenter = $('#callCenter').html(); 
      alert(callCenter); 
      $('#callCenter').remove(); 
      $('body').prepend("<div id='callCenter'>"+callCenter+"</div>"); 
    }); 
</script> 
<![endif]--> 

問題は、アラートが

enter image description here

だからclasenamesは一種の

を失っている( "" なし)のようなものを示しているということです代わりに

<!--[if lte IE 7]> 
<script type="text/javascript"> 
    $(document).ready(function() { 
      $('#callCenter').prependTo('body'); 
    }); 
</script> 
<![endif]--> 

にしようと<span class="clasname">

-EDIT-

のは、これがInternet Explorerのものですか?

+0

どのように失われますか?彼らはまだそこにいるように見えます。 –

+1

あなたの問題は何ですか? 'var callCenter'が適切な内容を持っているかどうかを見るために、' remove() 'の後ろに' alert() 'を動かしてください。アトリビュートの周りに引用符があるかどうかは関係ありません。アラートボックスの内容は、MS IEがHTMLをパースしているときの内容です... – feeela

答えて

1

これは動作するはずです。

<!--[if lte IE 7]> 
<script type="text/javascript"> 
    $(document).ready(function() {    
      var callCenter = $('#callCenter').remove().prependTo(document.body); 
    }); 
</script> 
<![endif]--> 
+0

私はremove() –