jQuery.clone() IE problem

Posted by mofle on Stack Overflow See other posts from Stack Overflow or by mofle
Published on 2010-05-20T13:57:41Z Indexed on 2010/05/20 14:00 UTC
Read the original article Hit count: 303

Filed under:
|
|
|
|

I'm have some that uses jQuery.clone() to get the html of a page and then add it to a pre tag. It works correctly in Firefox and Chrome, but nothing happens in IE:

<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script>
$(function(){

  $('button').click(function(){
    var $clone = $('html').clone();
    $('#output').text($clone.html());
  });

});
</script>
<style>
  article, aside, figure, footer, header, hgroup, 
  menu, nav, section { display: block; }
</style>
</head>
<body>
  <button>run test</button>
  <pre id="output"></pre>
</body>
</html>

Is there any know bug with IE that prevents this, or am I doing something wrong?

(I need to clone it because I'm doing some changes to it before outputting it)

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about clone