解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script src="jquery-1.8.3.min.js"></script>
    <script>
    window.onload=function(){$("#p1").clone().appendTo($("#p2"));}
    </script>
    </head>
    <body>
    <pre id='p1'>
      123
        sdf
           sdf
    </pre><pre id='p2'></pre>
    </body>
    </html>
      

  2.   


        var str = document.getElementById('pre1').innerHTML;
        alert(str.charCodeAt(1))
        document.getElementById('pre2').outerHTML = '<pre>'+str+'</pre>';
    判断为ie8-就用outerHTML,否则就用innerHTML,自己修改上面红色的兼容代码
      

  3.   

    谢谢版主的指教。  
    jquery我基本上不用,所以1楼贴的代码用不上了。