<script type="text/javascript">
$(function(){
alert($(document).html());
})
</script>

解决方案 »

  1.   

    你这么写是不是因为dom还没加载完?
    试试这样写(不知道行不行)
    $(document).ready(function(
        alert($(document).html());
    ));
    大概这个样子,我怀疑是因为你这么写是直接运行,dom还没开始加载
      

  2.   

    我的是dom加载以后运行的
    你的不知道,怀疑是dom还没加载就开始运行了。
      

  3.   

    <script type="text/javascript">
    (function($) {
        $.fn.outerHTML = function(s) {
            return (s) 
                ? this.before(s).remove() 
                : $('<p>').append(this.eq(0).clone()).html();
        }
    })(jQuery);
    $(function(){
        alert($(document).outerHTML());    
    })
    </script>
      

  4.   


    <script type="text/javascript">
    (function($) {
      $.fn.outerHTML = function(s) {
      return (s)  
      ? this.before(s).remove()  
      : $('<p>').append(this.eq(0).clone()).html();
      }
    })(jQuery);
    $(function(){
      alert($(document).outerHTML());   
    })
    </script>